Mike D
Mike D

Reputation: 4946

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?

Upvotes: 12

Views: 8007

Answers (3)

yoAlex5
yoAlex5

Reputation: 34175

Xcode debug app after launch

  1. -> Run -> Info -> Wait for the executable to be launched
  1. Debug -> Attach to Process by PID or Name... -> <app_name> -> Attach

after that you will see in Debug navigator that debugger is waiting for attach(if app is removed from memory)

Upvotes: -1

Wes Johnson
Wes Johnson

Reputation: 3101

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.

Upvotes: 3

Ole Begemann
Ole Begemann

Reputation: 135540

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.

Upvotes: 24

Related Questions