Hi,
the LaunchAgent is implemented with this (cutout):
@interface ServiceDelegate : NSObject
@end
@implementation ServiceDelegate
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(pEpMacOSAdapterProtocol)];
pEpMacOSAdapter *exportedObject = [pEpMacOSAdapter new];
newConnection.exportedObject = exportedObject;
[newConnection resume];
return YES;
}
@end
int main(int argc, const char *argv[])
{
ServiceDelegate *delegate = [ServiceDelegate new];
NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName:@"foundation.pEp.adapter.macOS"];
[listener resume];
[[NSRunLoop currentRunLoop] run];
return 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict> <key>Label</key>
<string>foundation.pEp.adapter.macOS</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Application Support/pEp/foundation.pEp.adapter.macOS</string>
</array>
<key>MachServices</key>
<dict>
<key>foundation.pEp.adapter.macOS</key>
<true/>
</dict>
</dict>
</plist>
The App is implemented with this (cutout):
func proxyErrorHandler(err: Error) -> Void {
NSLog("%@", err.localizedDescription)
statusText.title = NSLocalizedString("Connection failed", comment: "")
}
internal func applicationDidFinishLaunching(_ aNotification: Notification) {
connection = NSXPCConnection.init(machServiceName: "foundation.pEp.adapter.macOS")
if connection != nil {
connection.remoteObjectInterface = NSXPCInterface.init(with: pEpMacOSAdapterProtocol.self)
connection.resume()
statusText.title = NSLocalizedString("Connecting…", comment: "")
proxy = connection.remoteObjectProxyWithErrorHandler(proxyErrorHandler) as? pEpMacOSAdapterProtocol
proxy?.subscribeForUpdate(downloadNotification: notifyDownload)
}
else {
NSLog("pEpNotifications: %@", "cannot connect to pEp.foundation.adapter.macOS")
}
}
I'm always getting proxyErrorHandler() called with "Couldn’t communicate with a helper application."
Any ideas?