How to attach debugger to iOS app after launch?

IosXcodeDebugging

Ios Problem Overview


I have an issue I am troubleshooting which occurs very infrequently and doesn't seem to happen when I have things running under Xcode.

Is it possible to run an app normally (i.e. from Springboard) until my issue occurs, and then attach a debugger at that point?

I would prefer to do this without jailbreaking if possible.

Ios Solutions


Solution 1 - Ios

  • Attach your device connected your Mac
  • Debug > Attach to Process by PID or Name
  • In the dialog sheet, enter the name of your App as it appears in the Debug navigator when started via Xcode (e.g. Target's name not bundle-id).

If the app is already running, the debugger will attach to the running process. If it isn't running, it will wait for the app to launch and then attach.

Solution 2 - Ios

I'll leave this here since neither of the other 2 answers gave me quite enough detail without a little bit of a struggle.

  1. Run your app in the simulator and take note of the name in the Debug navigator enter image description here

  2. Plug in your device and don't forget to select your device as the target enter image description here

  3. Debug > Attach to Process > By Process Identifier (PID) or Name enter image description here

  4. Enter the name from step 1 and attach. That should be all you have to do. enter image description here

Solution 3 - Ios

In Xcode 5.0.1 and 6 it's the menu bar items:

Debug > Attach to Process > By Process Identifier (PID) or Name...

Solution 4 - Ios

In Xcode 7 it's just:

Debug > Attach to Process by PID or Name...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLocksleyuView Question on Stackoverflow
Solution 1 - IosOle BegemannView Answer on Stackoverflow
Solution 2 - IosAdam JohnsView Answer on Stackoverflow
Solution 3 - IosPiTheNumberView Answer on Stackoverflow
Solution 4 - IosJapesView Answer on Stackoverflow