这是我目前使用的命令:
instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate / Users / X / Library / Developer / Xcode / DerivedData / TestiPhoneAutomation2-dyufpxsavtdqkybpagcoawdudzid / Build / Products / Debug-iphoneos / TestiPhoneAutomation2.app -e UIASCRIPT“/Users/X/Workspaces/TestiPhoneAutomation/test2.js”-e UIARESULTSPATH“/ Users / X / Workspaces / TestiPhoneAutomation2 /”-w 80bf5b … UDID. ..dfb52543 -v
它在模拟器上运行良好(通过Debug-iphonesimulator替换Debug-iphoneos,它在这种情况下也忽略了-w),但是如果我使用为设备编译的应用程序启动它它会崩溃(我尝试使用发布和调试,我得到相同的结果).
我得到的错误是:
posix spawn failure; aborting launch (binary ==
/Users/X/Library/Developer/Xcode/DerivedData/TestiPhoneAutomation2-dyufpxsavtdqkybpagcoawdudzid/Build/Products/Debug-iphoneos/TestiPhoneAutomation2.app/TestiPhoneAutomation2).
2012-10-03 12:10:36.609 instruments[76151:1603] Recording cancelled :
At least one target Failed to launch; aborting run Instruments Trace
Error : Failed to start trace.
解决方法
我使用的命令行如下(使用Xcode 4.6):
instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w <device_id> <app_name> -e UIASCRIPT <path_to_script> -e UIARESULTSPATH <path_to_results>