xnyhps
xnyhps

Reputation: 3316

Creating an NSXPCConnection from an XPC service

I'm trying to create an application with an XPC service "A", which in turn tries to communicate with an XPC service "B". However, it is not working.

If I copy both XPC services to Contents/XPCServices in the main app, the invalidationHandler of the NSXPCConnection in A is called immediately and B does not appear to start at all.

If I copy the nested XPC service to Contents/XPCServices/A.xpc/Contents/XPCServices, then it starts B, but it immediately crashes with:

Dyld Error Message:
  Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: App.app/Contents/XPCServices/A.xpc/Contents/XPCServices/B.xpc/Contents/MacOS/B
  Reason: image not found

libswiftCore.dylib exists in the Contents/Frameworks folder of the app, A and B.

(The other suggestions I found for the Library not loaded: @rpath/libswiftCore.dylib error did not help: changing code signing identities, setting Runpath Search Paths.)

What am I doing wrong?

I know I can initialize the connection to B from the main app, and then pass it as an anonymousListener to A, but this sounds ugly.

Upvotes: 2

Views: 1370

Answers (1)

xnyhps
xnyhps

Reputation: 3316

It works now after adding @loader_path/../../../../Frameworks to the Runpath Search Paths of B.

Upvotes: 2

Related Questions