I'm trying to get my app to communicate with a FinderSync extension using XPC.
In my app, I run the listener:
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:_serviceName];
_xpcListener.delegate = self;
[_xpcListener resume];
Where _serviceName="a.b.c.d.e.f"
In Info.plist of the app bundle, I have:
<key>MachServices</key>
<dict>
<key>a.b.c.d.e.f</key>
<true/>
</dict>
In the FinderSync ext, I try to connect to the XPC service:
_xpcConnection = [[NSXPCConnection alloc] initWithMachServiceName:_serviceName options:0];
...
[_xpcConnection resume];
It works in debug, but not when the app is installed.
In this case, _xpcConnection.invalidationHandler is called.
The FinderSync ext belongs to the app bundle.
The .entitlements of the App:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "...">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>a.b.c.d.e</string>
</array>
</dict>
</plist>
The .entitlements of the FinderSync:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "...">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>a.b.c.d.e</string>
</array>
</dict>
</plist>
The app is notorized:
% spctl --assess -vvvv /Applications/myApp.app
/Applications/myApp.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: ...
In the Console, just after the start of the listener, there is this error (3 times) for myApp process:
Trust evaluate failure: [leaf TemporalValidity]
So I checked its certificates, but they are valid:
% codesign -dvvvv --extract-certificates /Applications/myApp.app
% openssl x509 -inform DER -in codesign0 -text
...
Validity
Not Before: Jun 22 11:59:25 2020 GMT
Not After : Jun 23 11:59:25 2025 GMT
..
% openssl x509 -inform DER -in codesign1 -text
...
Validity
Not Before: Feb 1 22:12:15 2012 GMT
Not After : Feb 1 22:12:15 2027 GMT
...
% openssl x509 -inform DER -in codesign2 -text
...
Validity
Not Before: Apr 25 21:40:36 2006 GMT
Not After : Feb 9 21:40:36 2035 GMT
...
The computer date is Ok:
% date
Thu Apr 8 09:20:44 CEST 2021
In the console, there is also this error for tccd process:
Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for accessing={identifier=a.b.c.d.e, pid=12245, auid=501, euid=501, binary_path=/Applications/myApp.app/Contents/PlugIns/Extension.appex/Contents/MacOS/Extension}, requesting={identifier=com.apple.appleeventsd, pid=328, auid=55, euid=55, binary_path=/System/Library/CoreServices/appleeventsd},
I tried to add this com.apple.security.automation.apple-events entitlement to App and ext, but it didn't fix the problem.
How can I debug this issue?
Thank you.
The thing is initWithMachServiceName must be called with:
from the app: the full path of the login item bundle, i.e. /Applications/myApp.app/Contents/Library/LoginItems/a.b.c.d.e.LoginItemAgent.app
from the FinderSync ext: the bundle id of the login item, i.e. a.b.c.d.e.LoginItemAgent