(Xcode 4.5)
When running instruments from the command line it works the first time but then it won't run again until after I reboot.
The verbose output from Instruments includes this:
Instruments : Loading template 'file://localhost/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate'
Instruments : Setting Instrument Trace Command : Instrument Command (purpose:Idle; output destination:file://localhost/Users/xxxxx/instrumentscli0.trace)
Instruments : Trace Command Recognized
Instruments : Instrument 'Automation - MyProject' rejected command 'Instrument Command (purpose:Trace; output destination:file://localhost/Users/xxxxx/instrumentscli0.trace)' for target 'Executable (name:MyProject; arguments:)'
Instruments : Instruments Rejected Command
Instruments Trace Error : Failed to start trace.
The command line I'm using to run instruments is this (split onto multiple lines for clarity):
instruments -v -w <DeviceID>
-t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
/Users/xxxxx/dev/MyProject/build/Debug-iphoneos/MyProject.app
-e UIASCRIPT /Users/xxxxx/dev/MyProject/UIAutoTests/some_test.js
I've tried comparing what processes were running before and after the first (successful) run using ps
and what files/pipes were open before and after using lsof
, but I can't find anything to suggest why it won't run more than once.
The error seems to suggest that the automation instrument within instruments is rejecting the purpose:Trace
command, so I've tried deleting the output trace directory (in case the auto-incremented filename was causing a problem), I've tried running instruments with a different template between runs to see if this clears whatever is blocking it, but I can't get it to work more than once per reboot.
My suspicion is that there is some invalid state in the Automation instrument or in a shared library used by instruments. I need a way to reset this state from the command line so that I can run the automated tests reliably on a CI server.
Is there a way to compare what shared libraries are loaded before/after and unload them? Does anyone have any other ideas of what might be persisting and how to reset it?