XPC service not as a separate Target but an inbuilt class that implements listener delegate in the app.All examples I see online have separate target that make a xpc service tool and copies it to app resources folder for supporting incoming connections. Is there a way to do it like I want ?
-
2The whole point of using XPC is to create separate binaries with code limited to their function, assign them limited privileges and communicate with each other through inter-process communication. I don't know if it's possible to use any of the XPC apis within a single binary, but why bother with XPC at all unless you are going to divide your application's components up? – BergQuester Oct 21 '13 at 08:28
-
1XPC is dealing with a separate process. If you don't have a separate process, then you have better methods of communication... notifications, kvo, custom delegates etc. – Grady Player Oct 21 '13 at 19:19
-
Just to correct @BergQuester. The default ways of running XPC services are through on binary, but they can include several i.e. libraries etc... 99.9999% of the time I've never had to have separate binaries (unless Licenses required me to). – Adrian Sluyters Apr 11 '15 at 17:49
1 Answers
No there isn't.. Sorry to be blunt and spoil your weekend.
XPC's run as a service to something i.e.
YouApp.app
Contents
XPCServices/
SomeService.xpc
Don't let the "xpc" extension fool you, it's noting but an "app" to put it in layman terms.
When the "YouApp.app" fires up, launchd (the big daddy that makes your mac tic) is notified of it and investigations begin.
The reason why launchd is so fussy about them (libxpc) is because they run at a low level and potentially could be harmful, BUT... because they run at allow level, they're extremely nippy and do their job efficiently.
A good example for a beginner to get started with is:
Basically, there's 1 app and 2 XPC services.
and the flow goes as follows:
1) App fires up 2) launchd (amongst other things authorises XPC services to run) 3) the app asks one service to download something off the internet you can enter in the URL 4) that service downloads it, saves it in a place that all the services (and the app) have access too i.e. the Application Group. 5) Then the app asks the other service to "zip" it.
and that's it.
It does take a while to get around at first, and the most frustrating thing is code-signing.
Just a fore-warning. If you want this to run nicely, you'll probably wind up codesiging from the terminal rather than letting XCode it.
Another thing to keep an eye open for is the "schemes". Make sure that you have the XPC debugging settings set correctly or it'll just appear like nothings happening at all
Finally, Console is your friend :D Keep it open when debugging XPX.

- 2,186
- 1
- 16
- 21