Thank you for your answer.
Yikes! You’re using Distributed Objects (DO). Don’t do that. It’s been deprecated for a while now and for good reason. It’s deeply broken.
It's an old app and I didn't want to rewrite everything (now). The migration is not trivial...
The standard way to set up comms between an app and an ES sysex is via NSEndpointSecurityMachServiceName.
Ok, I will try to get by using this.
Post
Replies
Boosts
Views
Activity
Hello!
So, I have added an XPC service to my application.
I'm able to communicate between the app and the service but still not between the system extension and the service.
The code is almost the same for the app and the system extension The only difference is:
_xpcConnection = [[NSXPCConnection alloc] initWithServiceName:_serviceName]; // App code
_xpcConnection = [[NSXPCConnection alloc] initWithMachServiceName:_serviceName options:0]; // Sys ext code
The interruptionHandler and invalidationHandler don't catch any error.
I don't see any error in the Console.
The service and sys ext belong to the same app group.
I have added NSEndpointSecurityMachServiceName to the Info.plist of the sys ext.
I have also tried to add it to the Info.plist of the service (not sure it's usefull or not).
"sudo launchctl procinfo ... " for the service:
endpoints = {
"a.b.c.d.e" = {
port = 0x105c77
active = 1
managed = 1
reset = 0
hide = 0
}
}
"sudo launchctl procinfo ... " for the sys ext:
endpoints = {
"a.b.c.d.e" = {
port = 0xf5d5b
active = 0
managed = 1
reset = 0
hide = 0
}
}
How can I debug that?
Thank you.
If you add an XPC Service to an app then the service is registered in the app’s namespace. Only that app can access it.
So, what should I do to communicate between my app and my sys ext?
Not solved, but I cannot remove the "Solved" badge I set by mistake...
Finally, I managed to make it work, I did not understand that the sys ext had to be the listener.
Thank you for your help.
It's really solved this time!
I have also tried without success to set com.apple.security.temporary-exception.mach-register.global-name/com.apple.security.temporary-exception.mach-lookup.global-name entitlements.
In myApp.entitlements:
...
keycom.apple.security.temporary-exception.mach-register.global-name/key
array
stringa.b.c.d.e.f/string
/array
And in Extension.entitlements:
...
keycom.apple.security.temporary-exception.mach-lookup.global-name/key
array
stringa.b.c.d.e.f/string
/array
Should I use an XPC login item app between the app and the extension?
myApp = XPC login item app = FinderSync ext
By dint of searching, I came across the AppLoginItemXPCDemo example, but it dates from 2012 ... No better solution has been proposed by Apple since? It seems like it's a common problem to get an application to communicate with a FinderSync extension ...
Ok, thank you.
So I'm trying to make working the AppLoginItemXPCDemo example.
In the readme, I found that "The bundle identifier of a login item must start with your Team ID", but my Team ID starts with a figure and this is not accepted by XCode.
Is there a solution?
So, I've been able to set my bundle id starting with a figure from the Build Settings tab...
Now my app can communicate with the login item agent, but the FinderSync, still not...
I found this error in the Console:
Sandbox: Extension(7145) deny(1) file-read-data .....myApp.app/Contents/Library/LoginItems/a.b.c.d.e.LoginItemAgent.app
The app, FinderSync ext and login item agent are all in the same App Group, sandboxed and signed with "Apple Development" (debuging in XCode).
Any idea?
I finally managed to make it working.
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
Thank you for your answer.
But doing what you explained, the error is nearly the same.
NSXPCConnection: 0x12d834ab0 connection on anonymousListener or serviceListener from pid 36952: Exception caught during decoding of received selector hello, dropping incoming message.
Exception: NSXPCDecoder: 0x10c9e6000 received a message or reply block that is not in the interface of the remote object (hello), dropping.
(
0 CoreFoundation 0x00007fff205f56af __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff2032d3c9 objc_exception_throw + 48
2 Foundation 0x00007fff212c73e4 -[NSXPCDecoder __decodeXPCObject:allowingSimpleMessageSend:outInvocation:outArguments:outArgumentsMaxCount:outMethodSignature:outSelector:isReply:replySelector:interface:] + 2244
3 Foundation 0x00007fff21312001 -[NSXPCDecoder _decodeMessageFromXPCObject:allowingSimpleMessageSend:outInvocation:outArguments:outArgumentsMaxCount:outMethodSignature:outSelector:interface:] + 33
4 Foundation 0x00007fff21310e3b -[NSXPCConnection _decodeAndInvokeMessageWithEvent:flags:] + 418
5 Foundation 0x00007fff212c8d49 message_handler + 206
6 libxpc.dylib 0x00007fff201c6c28 _xpc_connection_call_event_handler + 56
7 libxpc.dylib 0x00007fff201c5a9c _xpc_connection_mach_event + 935
8 libdispatch.dylib 0x00007fff202d8867 _dispatch_client_callout4 + 9
9 libdispatch.dylib 0x00007fff202efa47 _dispatch_mach_msg_invoke + 441
10 libdispatch.dylib 0x00007fff202de4a7 _dispatch_lane_serial_drain + 263
11 libdispatch.dylib 0x00007fff202f05b8 _dispatch_mach_invoke + 498
12 libdispatch.dylib 0x00007fff202de4a7 _dispatch_lane_serial_drain + 263
13 libdispatch.dylib 0x00007fff202df0fe _dispatch_lane_invoke + 426
14 libdispatch.dylib 0x00007fff202e8c5d _dispatch_workloop_worker_thread + 819
15 libsystem_pthread.dylib 0x00007fff20480499 _pthread_wqthread + 314
16 libsystem_pthread.dylib 0x00007fff2047f467 start_wqthread + 15
Problem solved. It was due to 2 different structures with the same name.
Here it is: FB9110597 (Finder badges refresh issue)
Thank you for your help.
So, the entitlements claimed by the sysex are:
% codesign -d --entitlements :- /Applications/myApp.app/Contents/Library/SystemExtensions/a.b.c.d.e.Extension.systemextension
Executable=/Applications/myApp.app/Contents/Library/SystemExtensions/a.b.c.d.e.Extension.systemextension/Contents/MacOS/a.b.c.d.e.Extension
?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
keycom.apple.developer.endpoint-security.client/key
true/
keycom.apple.security.application-groups/key
array
string.../string
/array
/dict
/plist
com.apple.developer.endpoint-security.client is in the sysex's profile.
com.apple.security.application-groups seems to be missing.
I have updated my provisioning profile to add App Groups, but the entitlements returned by the "security cms -D -i ..." command are still the same, and the "Code signature invalid" error persists.
keyEntitlements/key
dict
keycom.apple.developer.endpoint-security.client/key
true/
keycom.apple.developer.system-extension.install/key
true/
keycom.apple.application-identifier/key
string....a.b.c.d.e.Extension/string
keykeychain-access-groups/key
array
string....*/string
/array
keycom.apple.developer.team-identifier/key
string.../string
/dict
I found that my app doesn't have an embedded.provisionprofile file in the Contents folder.
The bundle is not generated by XCode.
Should I add the profile manually or is there a command to do that? (no codesign option apparently)
After adding manually the profile to the app, the issue persists.
So now, the entitlements claimed by the app are:
% codesign -d --entitlements :- /Applications/myApp.app
Executable=/Applications/myApp.app/Contents/MacOS/myApp
?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
keycom.apple.developer.system-extension.install/key
true/
keycom.apple.security.application-groups/key
array
string....a.b.c.d/string
/array
/dict
/plist
And the capabilities of the app:
% security cms -D -i /Applications/myApp.app/Contents/embedded.provisionprofile
?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
keyAppIDName/key
string.../string
keyApplicationIdentifierPrefix/key
array
string.../string
/array
keyCreationDate/key
date2021-05-20T06:30:38Z/date
keyPlatform/key
array
stringOSX/string
/array
keyIsXcodeManaged/key
false/
keyDeveloperCertificates/key
array
dataMIIFtjCCBJ6gAwIBAgIIDPP2OBmNMQwwDQYJKoZIhvcNAQELBQAweTEtMCsGA1UEAwwkRGV2ZWxvcGVyIElEIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwHhcNMjAwNjIyMTE1OTI1WhcNMjUwNjIzMTE1OTI1WjCBpTEaMBgGCgmSJomT8ixkAQEMCjg2NFZEQ1MyUVkxRTBDBgNVBAMMPERldmVsb3BlciBJRCBBcHBsaWNhdGlvbjogSW5mb21hbmlhayBOZXR3b3JrIFNBICg4NjRWRENTMlFZKTETMBEGA1UECwwKODY0VkRDUzJRWTEeMBwGA1UECgwVSW5mb21hbmlhayBOZXR3b3JrIFNBMQswCQYDVQQ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xNjAwMDAwMFowEwYKKoZIhvdjZAYBDQEB/wQCBQAwDQYJKoZIhvcNAQELBQADggEBABL6WyRaT4OIK8kEpcbAiLyy3J2MRuB9sWIyQR0iYoqZyd3D+I+kEhd25UCuMyxUN48nK1juNoKdHqtkEjl6xJqOioNMAGbBga3jHl8LTmOWZ8u5Vg2ODzsI2uX/oTmHelh1g6dAxk6nl2UBhiJdCTpszJXMPvOHUqIpbH8kRHhQUq+OoRXkkB32bJPd/fLyPjxnPz30tN4OFu6ms6rO08e1Z9avhQntwAMPi6OYy3LAED2n7NOSkdtpP8j9rFCz6yrcZyNjG0D045G1bIA8mVzU95j5bc68Bpb4NUKxC9vqkoUbNbM8vkTOVJmceuBqt3i+3bLRnfkeFwKrtDSeP00=/data
/array
keyEntitlements/key
dict
keycom.apple.developer.system-extension.install/key
true/
keycom.apple.application-identifier/key
string....a.b.c.d.e/string
keykeychain-access-groups/key
array
string....*/string
/array
keycom.apple.developer.team-identifier/key
string.../string
/dict
keyExpirationDate/key
date2039-05-16T06:30:38Z/date
keyName/key
string.../string
keyProvisionsAllDevices/key
true/
keyTeamIdentifier/key
array
string.../string
/array
keyTeamName/key
string.../string
keyTimeToLive/key
integer6570/integer
keyUUID/key
stringcde3e69d-9c21-4ffc-94b3-4379efae014a/string
keyVersion/key
integer1/integer
/dict
/plist
To sum up, the app has got "com.apple.developer.system-extension.install" and the sysext "com.apple.developer.endpoint-security.client".
What is missing?