我想使用 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.3 iPhone 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/