Error 159 - Sandbox restriction when connecting to XPC service

Hello Apple Developer Community,

I'm encountering an issue with my macOS application where I'm receiving the following error message:

Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.FxPlugTestXPC was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.FxPlugTestXPC was invalidated: failed at lookup with error 159 - Sandbox restriction.}

This error occurs when my application tries to establish a connection to an XPC service named com.FxPlugTestXPC. It appears to be related to a sandbox restriction, but I'm unsure how to resolve it.

I've checked the sandboxing entitlements and ensured that the necessary permissions are in place. However, the issue persists.

Has anyone encountered a similar error before? If so, could you please provide guidance on how to troubleshoot and resolve this issue?

Any help or insights would be greatly appreciated.

Thank you.

this is some photos about my entitlements :

Answered by Jael in 785406022

I am facing a challenge when trying to create a filter for images using FxPlug, with the intention of later integrating it into Motion or Final Cut Pro. The problem arises when the connection to the XPC service I am using is lost.

When configuring the FxPlug SDK in Xcode and building the application, it appears that the XPC service is no longer available. This disconnection prevents my application from correctly interacting with the XPC service required for the image filter.

I would appreciate any guidance or suggestions on how to fix this issue and restore the connection to the XPC service so that my application can work as intended @DarrinC @eskimo

Who is advertising this com.FxPlugTestXPC service? Is it coming from an XPC service embedded within your app? Or from somewhere else?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Now I got this new Error

error description -> Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.FxPlugTestXPC was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.FxPlugTestXPC was invalidated: failed at lookup with error 3 - No such process.} 
, error user info -> {
    NSDebugDescription = "The connection to service named com.FxPlugTestXPC was invalidated: failed at lookup with error 3 - No such process.";
}  
 and error localizedDescription -> Couldn’t communicate with a helper application.

@eskimo

Connection invalidation means that the connection couldn’t be created due to some persistent issue. For other types of XPC named endpoints there are various possibilities as to what’s wrong, but for an embedded XPC service there’s really only one cause: Your XPC service is not set up correctly.

I recommend that you check the built binary rather than relying on what you see in your project. If you then uncover a problem, work backwards to figure out how it got there.

Things to check are:

  • Your XPC service is embedded correctly. It should be at MyApp.app/Contents/XPCServices/MyService.xpc. The MyService name doesn’t really matter because of the next point.

  • Check that its bundle ID is set correctly:

    % plutil -p MyApp.app/Contents/XPCServices/MyService.xpc/Contents/Info.plist
    {
      …
      "CFBundleIdentifier" => "com.example.my-app.my-service"
      …
    }
    
  • Check that you’re passing that bundle ID to NSXPCConnection.init(serviceName:).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Well I see that the problem only occurs when I add FxPlug SDK, I can create another new project and add an XPC service and absolutely nothing happens, in fact it responds very well and everything works, only when following the documentation https:// developer.apple.com/documentation/professional_video_applications/fxplug/building_an_fxplug_plug-in_manually?language=objc, the project gets corrupted and can no longer connect to my XPC service. @eskimo

Ah, OK, that’s very specific to the FxPlug SDK, which isn’t something I’m super familiar with. I’ve added the Professional Video Applications tag to your thread to see if someone with more experience in this technology can chime in.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Can you describe what you're trying to accomplish by having an app other than Final Cut Pro or Motion connect to your FxPlug? Are you trying to display something that doesn't fit in the inspector and want to ferry frames between the host app and your helper app, or something similar? If so, you probably need to use a different mechanism.

Also, are there any crash logs for your XPC service? If so, they may indicate further what the issue is.

Accepted Answer

I am facing a challenge when trying to create a filter for images using FxPlug, with the intention of later integrating it into Motion or Final Cut Pro. The problem arises when the connection to the XPC service I am using is lost.

When configuring the FxPlug SDK in Xcode and building the application, it appears that the XPC service is no longer available. This disconnection prevents my application from correctly interacting with the XPC service required for the image filter.

I would appreciate any guidance or suggestions on how to fix this issue and restore the connection to the XPC service so that my application can work as intended @DarrinC @eskimo

Can you show us the format of the built bundle on disk? It should be an application bundle that has a Contents/PlugIns bundle which contains your XPC service. The XPC service bundle should have a Contents/Frameworks folder that contains the FxPlug.framework and the PluginManager.framework. They should look something like this:

and

Also, please open /Applications/Utilities/Console.app and click on "Crash Reports" on the left-hand sidebar and see if there are any crashes for your XPC service. If so, please post one here so we can look at it. That will tell us exactly why your XPC service is crashing and disconnecting, if there is one.

One last thing, what does the main.m file of your XPC service look like? Is it calling [FxPrincipal startServicePrincipal];?

Ok, This is all that appears when I see the content,

but when I run the app and check the console I get this error.

and yes in my main I call

    [FxPrincipal startServicePrincipal];

@DarrinC

Any suggestions @eskimo @DarrinC ?

So there are a few things going on here that are not what I'm expecting. First, you shouldn't need to create a service delegate or a listener in your XPC. The FxPlug.framework should take care of that for you. You also can't do anything after the call to -startServicePrincipal, because that method never returns. It starts and runs the run loop for your XPC service. I highly recommend you create a new project from the Xcode template provided with the FxPlug SDK and look at how it's arranged. You can either start your plug-in from that project, or copy the various settings and code from that project into your existing Xcode project.

That said, the bundle of your wrapper app looks correct. It would also be instructive to go to the Finder and context-click on the "newXPCTest.pluginkit" bundle and choose "Show Package Contents" to ensure that bundle is built correctly.

I don't know what the error message from tccd is talking about. Are you attempting to use Apple Events in your plug-in? Have you tried adding the entitlement that the error message suggests?

It seems that the delegate suggests it in their Apple instructions, and it's even pre-built when adding an XPC service using the Xcode template. However, the guidance from Apple appears somewhat vague, lacking specific instructions on utilizing FxPlug and setting up the template in Xcode. Despite downloading Final Cut Pro during its trial period, there's no clear indication within the app on creating any template in Xcode. Motion lacks a trial period altogether.

I've diligently followed Apple's instructions step by step, yet I'm puzzled as to why it's not functioning as expected. I'll include some contents of the pluginkit package for further context.

@DarrinC

OK, so it looks like your XPC bundle is built correctly, except that for some reason the FxPlug.framework and PluginManager.framework are also being copied into the Resources folder. You should remove the build phase that does that.

If you installed the SDK from the .dmg, then Xcode should have a template for FxPlug 4 plug-ins. You can access it by opening the "File" menu, and from the "New" sub-menu, choose "Project…". When presented with the New Project dialog, you can enter a filter for "FxPlug" and it should show you the template for an FxPlug:

Once you've done that and built it, it still won't show up in Final Cut Pro until you've created a Final Cut Pro Effect Template for it. In order to do that, you need to use Motion. There is no demo version of Motion at this time, so you must either purchase it or use a friend's copy.

Yes, I see that it works, but it is built totally different from what it says in the documentation.

Is there or will there be any other document where I can see a tutorial on how to use FxPlug? The truth is, the project that creates the template is extremely different and totally different from the references that the documentation makes. @DarrinC

Error 159 - Sandbox restriction when connecting to XPC service
 
 
Q