Latest 1.2
Homepage https://github.com/google/macops-molxpcconnection
License Apache 2.0
Platforms osx 10.8
Dependencies MOLCodesignChecker
Authors

A wrapper around NSXPCListener and NSXPCConnection to provide client multiplexing,
signature validation of connecting clients, forced connection establishment and
different exported interfaces for privileged/unprivileged clients.

Installation

Install using CocoaPods.

pod 'MOLXPCConnection'

Example

Example server started by launchd where the launchd job has a MachServices key:

MOLXPCConnection *conn = [[MOLXPCConnection alloc] initServerWithName:@"MyServer"];
conn.privilegedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyServerProtocol)];
conn.exportedObject = myObject;
[conn resume];

Example client, connecting to above server:

MOLXPCConnection *conn = [[MOLXPCConnection alloc] initClientWithName:"MyServer" withOptions:0];
conn.remoteInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyServerProtocol)];
conn.invalidationHandler = ^{ NSLog(@"Connection invalidated") };
[conn resume];

The client can send a message to the server with:

[conn.remoteObjectProxy selectorInRemoteInterface];

One advantage of the way that MOLXPCConnection works over using NSXPCConnection directly is that from the client-side once the resume method has finished, the connection is either valid or the invalidation handler will be called. Ordinarily, the connection doesn’t actually get made until the first message is sent across it.

messages are always delivered on a background thread!

Documentation

Reference documentation is at CocoaDocs.org:

http://cocoadocs.org/docsets/MOLXPCConnection

Contributing

Patches to this library are very much welcome.
Please see the CONTRIBUTING file.

Latest podspec

{
    "name": "MOLXPCConnection",
    "version": "1.2",
    "platforms": {
        "osx": "10.8"
    },
    "license": {
        "type": "Apache 2.0",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/google/macops-molxpcconnection",
    "authors": {
        "Google Macops": "[email protected]"
    },
    "summary": "A macOS XPC connection class",
    "source": {
        "git": "https://github.com/google/macops-molxpcconnection.git",
        "tag": "v1.2"
    },
    "source_files": "Source/MOLXPCConnection/*.{h,m}",
    "dependencies": {
        "MOLCodesignChecker": [
            "~> 1.9"
        ]
    }
}

Pin It on Pinterest

Share This