Damien DeVille wrote:
Are you specifying the MachService you use for your XPC connection in
your launchd job?
I believe so. The launchd plist is:
==============
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.sil.KLMHelper</string>
<key>MachServices</key>
<dict>
<key>org.sil.KLMHelper</key>
<true/>
</dict>
<key>Program</key>
<string>/Library/PrivilegedHelperTools/org.sil.KLMHelper</string>
<key>ProgramArguments</key>
<array>
<string>/Library/PrivilegedHelperTools/org.sil.KLMHelper</string>
</array>
</dict>
</plist>
==============

The code to connect to the helper is:
==============
helperToolConnection = NSXPCConnection.init(machServiceName: toolIdentifier, options: NSXPCConnection.Options.privileged) helperToolConnection?.remoteObjectInterface = NSXPCInterface.init(with: Keyboard_Layout_HelperProtocol.self)
            helperToolConnection?.invalidationHandler = {
                self.helperToolConnection?.invalidationHandler = nil
                OperationQueue.main.addOperation({
                    self.helperToolConnection = nil
                })
            }
==============
where toolIdentifier is "org.sil.KLMHelper"

The code that invokes the code is like this:
==============
                let connection = connectionManager.helperToolConnection
let proxy = connection?.remoteObjectProxyWithErrorHandler { (error) in
                    NSApp.presentError(error)
                } as! Keyboard_Layout_HelperProtocol
                let authorization = connectionManager.authorization
                // Call the proxy with the appropriate code
proxy.authenticatedCreateDirectory(url: location, authorization: authorization) { handler($0, $1) }
==============

All of this is derived from Even Better Authorization Sample, translated to Swift.
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to