gpt4 book ai didi

objective-c - 如何从我的 Cocoa 应用程序在终端中运行命令?

转载 作者:行者123 更新时间:2023-12-03 16:40:52 25 4
gpt4 key购买 nike

我想使用 Instrument 通过我的 cocoa 应用程序在我的 iOS 模拟器上安装 .app。

这是我第一次开发 cocoa 应用程序,也是 NSTask。NSTask 需要一个启动路径,在我的情况下这是无关紧要的,因为这个命令可以从任何地方运行。这是我要运行的命令:

instruments -t/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -w“iPad Retina(7.1 模拟器)”“”

目前我有这个:

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/"];

NSString * commandTorun = @"instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -w \"iPad Retina (7.1 Simulator)\" \"<path to .app>" ";

NSArray *arguments = [NSArray arrayWithObjects:
@"-t" ,
[NSString stringWithFormat:@"%@", commandTorun],
nil];

NSLog(@"Run command:%@",commandTorun);
[task setArguments:arguments];
[task launch];

任何帮助将不胜感激。

谢谢

最佳答案

我们开始吧。

工作解决方案。代码7.3iPhone 6 (9.3)

 NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/Applications/Xcode 7.3.app/Contents/Developer/usr/bin/instruments"];
NSArray *arguments = [NSArray arrayWithObjects:
@"-t",
@"/Applications/Xcode 7.3.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate",
@"-w",
@"iPhone 6 (9.3)",
@"/Users/ab56353/Desktop/FirstTest.app",
@"-e",
@"UIASCRIPT",
@"/Users/ab56353/Desktop/TapGeneration.js",
nil];
[task setArguments:arguments];
[task launch];

注意:放置正确的 xcode 应用程序名称(/Applications/xcode 7.3)和模拟器或设备 udid(如果是物理设备)。

关于objective-c - 如何从我的 Cocoa 应用程序在终端中运行命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26748038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com