Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a Application Launch in Xcode and iOS

I have a very specific case that I need to debug. I need to examine what is happening when an application is relaunched after being killed (looking at what stored data is being read, etc.). If I kill the application from the device, the debugger stops (which makes sense).

The best method I can think of is killing the application, and re-launching from Xcode (without modifying any code). I am trying to investigate "real world" behaviour. Is this the best approach for my case, or is there another way to view what happening with Xcode?

like image 215
Mike D Avatar asked Jun 26 '12 13:06

Mike D


2 Answers

In the Scheme editor in Xcode, you can edit the Debug profile to have the debugger "Wait for XY.app to launch". If you then select Product -> Run, the debugger should wait until you launch the app manually on the device and then automatically attach to the running process.

like image 191
Ole Begemann Avatar answered Sep 19 '22 21:09

Ole Begemann


If you want to avoid the build & run phase altogether / changing build configs, you can achieve a cold-start reattach by:

  • going to Debug menu > Attach to Process by PID or Name...
  • putting your app name in the first input & clicking Attach

You'll then see "Waiting to attach to APPNAME on somedevice", and you can just reopen the app on the simulator.

like image 23
Wes Johnson Avatar answered Sep 18 '22 21:09

Wes Johnson