XPC between two Network Extension

Hi


I am wokring on two Network System Extensions (App Proxy and DNS Proxy) on 10.15. I would like send XPC messages betweek these extensions. In my implementation, I will always get "Connection Terminated" message, could not get idea how to move further.


My Proxy has listner:

- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {

newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyListenerXPCProtocol)];


MyListenerXPCService *exportedObject = [DNSXPCService new];

newConnection.exportedObject = exportedObject;

[newConnection resume];

}


-(void) startXPCListner {

NSString *machServiceName = @"<<MY TEAM ID>>.com.example.app-group.MyLisetenerSystemExtension";

MyXPCServiceDelegate *delegate = [MyXPCServiceDelegate new];

xpcListener_ = [[NSXPCListener alloc] initWithMachServiceName: machServiceName];

xpcListener_.delegate = delegate;

[xpcListener_ resume];

}


Lisetener entitlement file:

Key "com.apple.security.temporary-exception.mach-register.global-name" array value is "<<MY TEAM ID>>.com.example.app-group.MyListenerSystemExtension"


In Info.plist, NEMachServiceName has same <<MY TEAM ID>>.com.example.app-group.MyLisetenerSystemExtension".


App Proxy message sender:

-(void) sendTestXPCMsg {

NSXPCConnection *_connectionToService = [[NSXPCConnection alloc]

initWithMachServiceName: @"<<MY TEAM ID>>..com.example.app-group.MyListenerSystemExtension"

options:0];

//initWithServiceName:@"24W52P9M7W.com.example.app-group.MyListenerSystemExtension"]; <-- Tried with it, but same result.

_connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyListenerXPCProtocol)];


_connectionToService.interruptionHandler = ^{

NSLog(@"Connection Terminated");

};

_connectionToService.invalidationHandler = ^{

NSLog(@"Connection invalidated");

};

[_connectionToService resume];

[[_connectionToService remoteObjectProxy] upperCaseString:@"hello" withReply:^(NSString *aString) {

NSLog(@"Result string was: %@", aString);

}];

}


Sender entitilement:

com.apple.security.temporary-exception.mach-lookup.global-name array value is "<<MY TEAM ID>>.com.example.app-group.MyLisetenerSystemExtension".


Whenever sender sends a message, it always receives "Connection Terminated" message. I also tried with removing entitlement but always same result.


Could you please help me to solve it?


Regards,

Anand Choubey

Replies

My understanding is that both of your NEs will be loaded in the same sysex process, meaning that you don’t need to use IPC for this communication.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for your reply!


But Acitivety Monitor shows different Process id for each extension. Is it correct?


Regards,

Anand Choubey