I've had little luck with recovering from this problem once it happens. Killing processes rarely seems to succeed with this. I can tell you how I avoid it though: don't quit the simulator while your app is still running in the debugger.
I develop on a MacBook and to save battery I would often quit the simulator while debugging. Something gets munged up though and sometimes causes the app's process to get detached or hung or something to the point that XCode can no longer control it. After that this error begins appearing.
Always stop your app in XCode before quitting from the simulator and the problem won't happen.
I'm not sure what situation leads to it happening when debugging on the device directly. Maybe quitting the app by forcing it closed from Springboard? Or possibly disconnecting the cable while still debugging /shrug