4

I am trying to follow this post to run UIAutomation scripts on iOS devices from command line, but i can't make it work.

This is the command i am currently using : 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

It works well on simulator (replacing the Debug-iphoneos by Debug-iphonesimulator, it also ignore the -w in this case), but if i launch it using an application compiled for device it crash (i tried with release and debug, i get the same result).

The error i'm getting is :

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.

Community
  • 1
  • 1
LiohAu
  • 611
  • 12
  • 36

3 Answers3

3

I got this same error, but I didn't have multiple copies of Instruments running. I got this working by putting the -w UDID arguments before the application, and only using the name of the application (with the application already deployed to the device).

The command line I used is the following (with 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>

Andy
  • 30,088
  • 6
  • 78
  • 89
  • 1
    Thanks, This is working fine..., I was using the same command but "-w udid" location was different. Putting that after tracetemplate and before app-name worked superb for me – Mehul Thakkar Feb 05 '14 at 12:01
0

Pls check the sequence of UDID in command line in fact for all parameters also run on debug version of build only. Hope this works, because its working for me.

ExploringApple
  • 1,348
  • 2
  • 17
  • 30
0

For anyone else having this problem, I'll explain what worked for me and how I solved this.

I did the ps command to see which processes are running. I found that instruments was still running. I then did killall instruments and that killed the instruments process. I then did my instruments command and it worked perfect after that.

SirRupertIII
  • 12,324
  • 20
  • 72
  • 121