I'm building a view-based plugin architecture where I have a separate process for plugins and want to assign each plugin an NSView
. I've looked into CARemoteLayerServer/Client
and IOSurfaceRef
usage, but both of them only allow a single drawing view. A plugin's view may have many subviews, and can receive events like it were part of the main application. Any way to make this possible?

- 6,259
- 3
- 24
- 26
1 Answers
There's no way to interact with an NSView
directly across process boundaries. That said, CARemoteLayerServer
supports a layer tree, not just a single layer. This means that your UI would most certainly need to be constructed using layers, but NSView
can still be useful when it comes to the event handling aspects.
Both the client and the server can contain the shared remote layer inside their own NSViews
because you can create a layer-hosting NSView
and assign the shared layer to it. The NSView
can then intercept mouse and keyboard events which could be passed to the other process over the XPC connection for its own NSView
(which contains the shared layer) to interpret. I'm not entirely sure how fast this would be as I haven't experimented with it myself, but I would assume that it would be almost as instantaneous as interacting with a normal view.
If you're interested in playing around more with remote layers, there's a nice example project along with an accompanying SO post that you could check out