xpc services with ServiceType user

In the process of moving our app to sdk 10.12 we have also updated various app daemons to XPC Services. IT was the correct thing to do as the app is now more stable.

We are now encountering an issue and we are not understanding well how to solve it.

The XPC service we created will need to be enbedded in the main app and a couple of more Targets, Cocoa apps.

The issue at the moment is that for each Target that is running there is an independent instance of XPC Service launched.

What we are looking for is the ability to launch the various target using the same XPC Service instance.

I see an option in the XPC service plist to set either USER or APPLICATION

When we set for USER the issue seems to be the username or password access of the service to the keychain that is saved for the product bundle identifier name.

For example we have main app with com.company.MyApp and XPC Service com.company.MyApp.xpcservice

unless we are using Application with Join Session the xpc service does not work. Issue is that when we add a target com.company.MYapp.target and bundle the xpc service we change xpc service plist to USER witho join session option as we understnad you cant use it that way.


Does all this make sense ?

Anything ?

I'm pretty sure embedded XPC services are not designed to be shared between apps.


I would suggest installing a named launchd service. Once installed, all of your apps can connect with the service, using its XPC identifier.


Create a launchd plist and put in the right place (~/Library/LaunchAgents/). I prefer to create a hard link to the service executable in ~/Library/Applcation Support/..., then set the executable path in the plist to that hard link. You'll need to run launchctl to install/start the service the first time.


Once installed, you can connect to the service via a named XPC connection from as many apps as you like. You can have it launch on-demand, run continuously, and so forth, depending on the plist options you choose.


See man launchd.plist and launchctl

xpc services with ServiceType user
 
 
Q