views:

282

answers:

2

In the typical build and run sequence of XCode, you often have your app still running in the iPhone simulator from the last time. XCode helpfully asks if you would like to stop the executable before it installs and runs the newest build.

But how does XCode signal the iPhone simulator to stop the application?

And could I write a step into my build sequence to do the same to save having to dismiss this dialog?

A: 

well, you can write a script to kill the GBD process which is running your app. I don't know if that's what you had in mind, but that'll kill the process!

OTisler
+2  A: 

Applications in the simulator are full fledged processes. Anything that will kill a process can kill a simulated app. If you are debugging the process then gdb will trap the signal instead of letting the app die, so you have to kill gdb too. Something like this should do it:

killall gdb-i386-apple-darwin
killall $(PRODUCT_NAME)
drawnonward
Good tip! Indeed killall $(PRODUCT_NAME) will kill the simulator. But it seems this isn't what XCode does. XCode manages to stop the running app inside the simulator without the simulator itself needing to be restarted.It seems that even if I knew how to do this, or used the kill script technique, it wouldn't matter since XCode prompts you to stop the running executable in the simulator before any build phases are executed.Any idea what signal XCode sends to the simulator (or how it communicates with the simulator)? Thanks!