Reputation: 5586
I am trying to create a connection between an OSX app and a command line tool to work with distributed objects.
The connection is registered in the command line tool like this
[NSConnection serviceConnectionWithName:@"server" rootObject:extManager];
and an attempt to connect to the registered connection object is made from the app like this
self.serverConnection = [NSConnection connectionWithRegisteredName:@"server" host:nil];
When the app is NOT sandboxed the connection is made. When the app is sandboxed the connectionWithRegisteredName
returns nil.
I have tried adding a key and value to the entitlements and signing both the tool and the app with the team certificate but it doesn't work
<key>com.apple.security.application-groups</key>
<array>
<string><TEAM ID>.AppSuite</string>
</array>
What can I do to make the connection work when sandboxed?
Upvotes: 5
Views: 240
Reputation: 2887
The trick here is to use the app-group name as a prefix in the connection name. i.e.:
self.serverConnection = [NSConnection connectionWithRegisteredName:@"<TEAM ID>.AppSuite.server" host:nil];
Why?
Mach port names must begin with the application group identifier, followed by a period (.), followed by a name of your choosing.
For example, if your application group’s name is Z123456789.com.example.app-group, [...] You might create a Mach port named Z123456789.com.example.app-group.Port_of_Kobe.
Ref
Upvotes: 0