Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug XPC Services in XCode 4?

Tags:

xcode4

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?

like image 643
Mike T Avatar asked Jan 05 '12 15:01

Mike T


People also ask

What is XPC services on Mac?

macOS uses XPC services for basic inter-process communication between various processes, such as between the XPC Service daemon and third-party application privileged helper tools.

What is XPC services on Iphone?

The XPC Services API provides a lightweight mechanism for basic interprocess communication at the libSystem level. It allows you to create lightweight helper tools, called XPC services, that perform work on behalf of your app.

What is XPC used for?

Cross Process Communication (XPC) is a lightweight mechanism for interprocess communication integrated with Grand Central Dispatch (GCD) and launchd. XPC is designed as a native bidirectional way to exchange data. It follows a classic approach of data exchange over connection.


2 Answers

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.

like image 78
Khakionion Avatar answered Oct 15 '22 22:10

Khakionion


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.

like image 27
JackPearse Avatar answered Oct 15 '22 22:10

JackPearse