XPCKit is a Cocoa library for wrapping the XPC C APIs in a handy object-oriented model. It is merely meant as an object-oriented wrapper for the C library, and does not attempt to layer any additional semantics on top.
XPCKit is still in development and should not be considered production-ready just yet. See the Wish List below.
- Simplified Objective-C API for interacting with XPC processes
- Auto-boxing and auto-unboxing of objects from xpc_object_t objects to:
- NSNumber for bool, UInt64, Int64, and double types
- UUIDs (via a custom XPCUUID class)
- Block-based callbacks
- Probably safe to use from multiple threads
- Auto-boxing and auto-unboxing for
- NSData, backed by shared memory
Given this sample data, converted to an NSDictionary, you can see how:
- the client sends this command as a message, and
- the server receives this command, processes it, and sends the response back
You can use XPCKit in the client, server, or both; you just have to include the code. You can include XPCKit in one of three ways:
- Include the source files yourself (everything in XPCKit)
- Make a dependency of XPCKit's framework
- Make a dependency of XPCKit's static library (note: you will need to add linker flags
-ObjCto make this work properly)
Setting up the Client
- In your app, add the XPCKit source files, library or framework
- Set up an XPCConnection object with the name of your service
- Send it a message
Setting up the Server
- If you haven't already, create a new "XPC Service" target (located in Mac OS X > Framework & Library)
- Add the XPCKit source files, library or framework
- Link against the Foundation framework
- Rename "main.c" to "main.m"
- In your main function, call +[XPCService runServiceWithConnectionHandler:] to start listening for incoming connections.
- In the connection handler, set an event handler on the XPCConnection to receive messages.
Copyright 2011 XPCKit
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.