When you click the "stop" button to kill a simulator process in XCode, it leaves behind a zombie process. You'll see something like this:
diannao:options-test (09:04) $ ps -fu jjthrash
…
501 1503 228 0 Fri09AM ?? 0:00.00 (myIOSApp)
…
This may seem like a merely aesthetic annoyance, but the reality is these zombie processes take up allowed process count, and you'll eventually run out of processes on your system, leading to weird behavior and ultimately requiring you to reboot.
Thanks to this Stack Overflow Post answer: Xcode leaving zombie processes after running iOS tests/simulator I have been able to work out a scheme to minimize this problem.
The basic flow is as follows:
- In XCode, type
^⌘yto pause the process - In the debugger session, type
process detach - In the simulator, simulate going to home screen:
⌘h - In the simulator, kill the app:
⌘htwice to pull up processes, tap and hold on process icon, tap (-) icon.
The problem is, this is annoying, and annoying things are unreliable due to human nature.
I have automated steps 1–3 using Keyboard Maestro (script attached), but you can use whatever automation tool you like. In theory I could automate the whole thing, but gave up when I ended up playing with sleep statements.