views:

3275

answers:

7

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...

+6  A: 

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
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.
LucasTizma
The link you provided, while informative, doesn't apply to my particular issue. Please see my original, newly edited question above. Thanks!
LucasTizma
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
+1  A: 

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

Andrew Garrison
A: 

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

Nosredna
A: 

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
A: 

Xcode>preferences>debugging uncheck load symbols lazily

fixed the breakpoints not holding in device problem for me.

+2  A: 

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

MrDatabase
A: 

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