Question

I am creating a Print Dialog Extension (PDE) plugin. This plugin is called and displayed when a user Prints from different apps, e.g. TextEdit, Preview, Xcode, etc. Note that the plugin runs on top of the app that called the Print Plugin (for example, TextEdit).

Inside the plugin, I need to run an XPC service. I need an XPC service since the entitlements on the main app might not be sufficient for my needs, e.g. I need to connect to the network, and TextEdit does not have the required entitlements for network connection.

The problem is, I can't create an XPC connection. The handler always fire with XPC_ERROR_CONNECTION_INVALID.

1.) Is this because the PDE Plugin is not inside the main bundle/main app, e.g. Text Edit?
2.) If yes, how can I still run an XPC service within a PDE Plugin?
3.) If no, then why can't I successfully create an XPC connection?

Was it helpful?

Solution

I did not manage to get XPC to work inside a PDE plugin.

The XPC bundle must be inside the Contents/XPCServices directory of the main application bundle, but in my case, the main application bundle varies - depends on the app that opened the PDE Plugin, e.g. TextEdit or Preview. Putting the XPC bundle inside the PDE bundle did not work.

Due to this limitation, I have redesigned the flow of operation inside the PDE plugin. It now calls an external application (standalone) to do things that require network connection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top