15

Is it possible to actually use the Xcode debugger when running an iPhone app on the device rather than the simulator? i.e., can I have the device stop at breakpoints that I set in my code and step through the code as it runs on the device?

EDIT: I should mention that I am a registered developer with Apple and have a valid certificate. In fact, I can build and run iPhone applications on my device just fine. However, even in Debug mode, my application will not stop on breakpoints or output to the console when I run it on my device. If it helps, my application will function normally in debug mode (e.g., stopping at breakpoints) when I run in the simulator.

EDIT 2: I've tried resetting my phone, completely removing and reinstalling Xcode, creating a new project, changing all the settings mentioned in the answers on this page (as well as others), cleaning and building my project, Build and Debug... If I click Pause, it says "Error from Debugger: Quit". :( Maybe I'll try to debug on this device using Xcode on another computer and see what happens.

EDIT 3: Well, I tried using another computer using a fresh install of Xcode in a new project, and I still can't get device debugging to work. I have a suspicion that it's my iPhone or cable perhaps? I'd like to think that I'm not so incompetent that I've missed something so embarrassingly obvious, but I've double- and triple-checked all of the suggestions mentioned here.

EDIT 4: FINALLY got device debugging to work. I have a feeling that something low-level on my device was causing issues...nothing I did worked on my system. However, I installed Xcode on another system and device debugging on the same device (with the same cable) worked flawlessly. Directly after that, device debugging began working on my original machine, leading me to believe that some strange hardware flag was screwed up and somehow "reset" on the second machine. In any case, it works now... Thanks for all the help. :)

Also, I'm unsure if it's better to leave this question unanswered or pick the most "helpful" answer...

CIFilter
  • 8,647
  • 4
  • 46
  • 66
  • 1
    Lucas, I believe the correct thing to do would be to edit your question to be clear on your issue, and you give an answer yourself which you accept. So, I'd probably move at least some edits to that answer. – cregox Nov 10 '10 at 19:53
  • I don't really see how my question, with its edits, is not entirely clear. – CIFilter Nov 14 '10 at 02:12
  • sorry, I meant shorter. A lot shorter. :P - Your question title is answered by Lou Franco, but your actual question is a whole nother and you could answer it yourself as an answer rather than an edit. – cregox Nov 19 '10 at 13:30
  • I see what you mean. Yeah, sorry about that. – CIFilter Nov 20 '10 at 15:16
  • Great question, thanks! – Vladimir Despotovic Dec 28 '20 at 15:34

7 Answers7

10

Yes -- just use a device build. You have to get certificates and provision it.

This is a good description:

http://boga.wordpress.com/2008/07/16/debugging-ipod-provision-profilescertificates/

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
  • I figured it was a trivial thing. I do have certifications and provisioning profiles. The app will run on my device, but it will not halt at breakpoints or output to the console. And yes, I'm using a Device build in Debug mode. I wonder what I've screwed up. :-\ I'll take a look at that link and get back to you. – CIFilter Jun 11 '09 at 23:21
  • The link you provided, while informative, doesn't apply to my particular issue. Please see my original, newly edited question above. Thanks! – CIFilter Jun 11 '09 at 23:48
  • 1
    There are an irritatingly large number of ways that XCode can decide to ignore breakpoints. I think I've experienced at least 3 of them. http://stackoverflow.com/questions/64790/why-arent-my-breakpoints-working-in-xcode – Nosredna Jun 11 '09 at 23:49
4

Make sure to start debugging by pressing "Cmd-Y"... and not "Cmd-R" :-)

MrDatabase
  • 43,245
  • 41
  • 111
  • 153
2

You may try last trick in case nothing can help.

If your application launched successful on your device from XCode but did not stop at breakpoints - try press "pause" button after start in debug mode. If you will see application paused properly (do not react to user's action) add new breakpoint then press "run" to continue application execution. In some cases it may helps to stop at new breakpoint.

MikZ
  • 364
  • 2
  • 13
  • Has a similar problem with XCode not stopping on breakpoints after the upgrade from 4.2 to 4.3. This worked for me. – Jason George Mar 12 '12 at 01:23
1

Yes, just set your project to build for the Device.

Andrew Garrison
  • 6,977
  • 11
  • 50
  • 77
1

If you need to setup debugging for jailbroken iPhone (up to 2.2.1) (not pay 99 to Apple yet) follow next steps:

  • Install MobileInstallationPatch for your iPhone via Cydia (use Search Tab)

  • Switch off PROVISIONING_PROFILE at XCode: Go to /Developer/Platforms/iPhoneOS.platform/Info.plist, add next keys:

<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>

You may also add these keys to any project particularly at XCode, Project Build Settings, User-Defined variables.

Important! You may need to install and launch at least one legal app (any free one) from App Store first (before "Build and Go" step). Otherwise your application will be successfully installed by XCode to your device but may not be launched. Try this troubleshoot first in case of problem with app launching.

MikZ
  • 364
  • 2
  • 13
0

Yes. Debugger and performance tools work fine on the device. That's where I do most of my debugging.

Nosredna
  • 83,000
  • 15
  • 95
  • 122
0

Xcode>preferences>debugging uncheck load symbols lazily

fixed the breakpoints not holding in device problem for me.