XPC does not create any processes for XPC services

I am trying to create an XPC service, but the service does not seem to be created. In my main service method, the first thing I do is make some calls to syslog so that I can see if the service is really starting. These log messages never appear in the log.

I checked all the package identifiers, executable file names and package hierarchy, but still the services do not seem to be created. In the application, immediately after creating and sending a message through the XPC service connection, my event handler is called with the error XPC_ERROR_CONNECTION_INVALID. I am using C-based XPC APIs

Is there anything else I can try and do to make sure the XPC service is at least created?

+4
source share
3 answers

It turned out that I needed to encode the destination mark of the application and the purpose of the XPC service. This can be done in the build settings of the Xcode project and can be set to "Ad-hoc Code Sign" without requiring a Mac developer certificate.

enter image description here

+5
source

Also check your service name. I found that the default example in the project template does not include the full name. In the client code, I had to change this:

NSXPCConnection *connection = [[NSXPCConnection alloc] initWithServiceName:@"MyNetworkClient"]; 

:

 NSXPCConnection *connection = [[NSXPCConnection alloc] initWithServiceName:@"com.example.MyNetworkClient"]; 

Double-checking that the XPC Goal Set ID is what you use for the service name. In my case, it did not start XPC and did not show any errors or console logs.

+2
source

I had a similar error, but the solution was simple: a clean, clean build folder, build.

Then, by magic, he worked as intended.

+1
source

Source: https://habr.com/ru/post/1443084/


All Articles