Can anyone point me to the documentation on how to make Instruments run UIAutomation scripts and start the iPhone application with the debugger running in the Simulator?
Constraints: I only have iPhone 3g hardware to test with and debugging against the device with UIAutomation just does not reliably work. Normally the test scripts are just ran to make sure everything passes, but now a weird bug exists that only gets triggered when the UIAutomation script runs (which is a good thing). The bug cannot be duplicated in manual operation. There does not seem to be anyway to attach Instruments UIAutomation to a process already running in the simulator. There is no selection. Starting Instruments UIAutomation directly does not cause it to start with the debugger.
I would assume that there is some command line magic that can be configured in Instruments edit active target (environment variable, arguments, working directory) to make this happen, but I've not found the magic paragraph.
Thanks, Neil
This stumped me for a while, too -- especially since when the Automation Instrument is selected, the Instruments application explicitly says
Current instrumentation disallows attach
. The key is to realize that an app running in the simulator is visible in your host system as its own process, so attaching directly from GDB works well. These instructions are for XCode 4.2 (4C199) on Snow Leopard 10.6.8:Start your test in Instruments however you normally do (either directly from Instruments, or from Xcode 4's
Product -> Profile
. Pick whatever templates and scripts to get your automated test underway.Back in Xcode, under the menu
Product -> Attach to Process
, you should see your iOS app, listed by name, alongside all the other applications on your host computer. In fact, it very likely will be listed first, under the section headerLikely Targets
.If it's not visible, choose
View -> Debug Area -> Show Debug Area
so you can see the gdb console.Hit the pause button (
Product -> Debug -> Pause
) to interrupt your program. Set breakpoints, inspect, as usual.Then next question is: why can't I see my normal
NSLog()
output in the debugger console? Your app already bound itself to the console output streams, so the simplest place to look for its output is in OS X Console app (/Applications/Utilities/Console.app
) and look underDATABASE SEARCHES -> All Messages
.