XPC Communication between Editor app and user-compiled code

Hello! I'm trying to implement an editor app (macOS) that allows the user to write code, which will be compiled and executed, showing the result in the editor window.

Imagine it like SwiftUI previews, but the graphic output is created with Metal, not SwiftUI. I found that IOSurface can be used to share that kind of data over XPC, so I would not have to rely on the private NSRemoteView. However, I'm confused if it is, at all, possible for my editor app to connect to an XPC Service, that was NOT bundled with it (but compiled by it at runtime).

I succeeded to launch an XPC service defined as:

<?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>
	<key>Label</key>
	<string>com.myteam.myproject.service</string>
	<key>MachServices</key>
	<dict>
		<key>com.myteam.myproject.service</key>
		<true/>
	</dict>
    <key>Program</key>
    <string>/Path/to/service/run_my_service.sh</string>
</dict>
</plist>

But the call to

let connection = NSXPCConnection(machServiceName: "com.myteam.myproject.service")
let proxy = connection.remoteObjectProxyWithErrorHandler { error in
    continuation.resume(throwing: error)
} as? MyServiceProtocol

fails with

"The connection to service named com.myteam.myproject.service was invalidated: Connection init failed at lookup with error 3 - No such process."

I have added

<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<array>
    <string>com.myteam.myproject.service</string>
</array>

to my entitlements.

Since the tutorials I followed are quite old, I'm wondering if support for something like this was dropped at some point.

Thanks for any advice!

XPC Communication between Editor app and user-compiled code
 
 
Q