XPC between standard macOS host app and Catalyst helper.

My standard "native" Mac app uses Catalyst helper. Helper is registered as Login Item via SMLoginItemSetEnabled. I tried to establish XPC communication between these process but I failed.

Is it possible to configure XPC connection between these two apps (mac host and catalyst helper)?

As far as I can understand it is possible to create XPC connection in Catalyst via passing listener endpoint. However how to send this endpoint between helper and host app? NSXPCListener.init(machServiceName:) is not available for Catalyst app.

Lemme see if I have this straight:

  • You have a container app built using a non-Catalyst framework (AppKit or SwiftUI).

  • Inside that container app you have a Service Management login item, enabled with SMLoginItemSetEnabled.

  • That Service Management login item uses Mac Catalyst.

  • You want your login item to set up an XPC listener in the manner demonstrates by the AppSandboxLoginItemXPCDemo sample, that is, it by calling -[NSXPCListener initWithMachServiceName:options:] with its bundle ID.

  • You can’t do that because -[NSXPCListener initWithMachServiceName:options:] is not available in Mac Catalyst.

Is that right?

Share and Enjoy

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

Thanks for confirming. At this point I’m going to encourage you to file a bug against NSXPCListener requesting that -initWithMachServiceName:options: be made available to Mac Catalyst apps. Your use case is valid, but obscure, and so it’s likely that this was just omitted by accident.

Please post your bug number, just for the record.

As to what you can do about this… hmmm…

Do you plan to deploy via the Mac App Store? Or independently, using Developer ID signing?

Share and Enjoy

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

As you recommended, I have just filed a feedback raport: FB9942625.

Do you plan to deploy via the Mac App Store? Or independently, using Developer ID signing?

I plan to deploy via the Mac App Store.

In case of workarounds I have found 2 which I tested already and one additional which I didn't try.

  1. @AppStorage property wrapper in SwiftUI. It works across multiple processes in one App Group. Naturally is limited as always when using UsersDefaults and there is some delay (looks like debounce is happening under the hood), but for some small data exchange can be useful.

  2. Saving data to shared file system (shared App Group) and monitoring file system event via DispatchSource.makeFileSystemObjectSource. Works surprisingly well, however a little bit clunky in set up.

  3. Unix socket communication via shared file system. This one I didn't try, but it seems like possible solutions.

Do you have any other recommendations?

XPC between standard macOS host app and Catalyst helper.
 
 
Q