Note that there are some explanatory texts on larger screens.

plurals
  1. POEXC_BAD_INSTRUCTION when sending message to XPC Service
    primarykey
    data
    text
    <p>I'm trying to use an XPC Service for inter-process communication. I've added an XPC service target to my project, and then when I try doing a <code>xpc_connection_send_message</code> I get <code>EXC_BAD_INSTRUCTION</code>. As far as I can tell, I am correctly initializing and starting the connection.</p> <pre><code>serviceConnection = xpc_connection_create("com.foo.bar.MyService", dispatch_get_main_queue()); xpc_connection_set_event_handler(serviceConnection, ^(xpc_object_t event) { xpc_type_t type = xpc_get_type(event); if (type == XPC_TYPE_ERROR) { if (event == XPC_ERROR_CONNECTION_INTERRUPTED) { // The service has either cancaled itself, crashed, or been // terminated. The XPC connection is still valid and sending a // message to it will re-launch the service. If the service is // state-full, this is the time to initialize the new service. } else if (event == XPC_ERROR_CONNECTION_INVALID) { // The service is invalid. Either the service name supplied to // xpc_connection_create() is incorrect or we (this process) have // canceled the service; we can do any cleanup of appliation // state at this point. NSLog(@"Uh oh, connection invalid"); xpc_release(serviceConnection); serviceConnection = nil; //xpc_release(stack); //stack = NULL; } else { NSLog(@"Unknown XPC error."); } } }); xpc_connection_resume(serviceConnection); </code></pre> <p>and then to send the message</p> <pre><code>xpc_object_t message = xpc_data_create(NULL, 0); .... xpc_connection_send_message(serviceConnection, message); </code></pre> <p>Is there anything I'm missing here? Is it somehow failing to find and connect to the service?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload