6

I added an XPC Service to my project and I would like to set breakpoints and inspect variable contents in the debug area in XCode. Breakpoints that I set in the service's code are not recognized (obviously, the debugger is attached to the main apps process. How and I attach the debugger (manually or automatically) to the XPC Service process after my main app launches it? Is there some way to run the service alone and send it messages without it being launched from the main app?

2 Answers 2

9

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

Type in your XPC service process name. The next time launchd starts up your XPC service, Xcode will attach.

2
  • I should up vote this as this is the way that it should work. However, this process only repeatedly crashes Xcode 5.0.2.
    – ctpenrose
    Nov 20, 2013 at 20:10
  • If you have an easily reproducible crash in what clearly should be working, you should file a bug report at bugreport.apple.com.
    – Khakionion
    Nov 20, 2013 at 23:30
2

I am actually not sure how to attach the debugger. But you can still use "NSLog" for debug output on the console. Then start the "Console.app" in "/Applications/Utilities/Concole.app". Depending on your system language this app may have a different name (it's localized). It shows ALL NSLog outputs from all Applications which are running including your xpc-services.

It's not the debugger, but you will get informations out of your service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.