Communication between two process in macOS.

We have 2 process in our macOS application

  1. Daemon process written in golang
  2. Swift application

Currently, the communication between both the process are done with Unix domain socket. However, we are seeing significant amount of delay when large amount of data communication. We are looking for some faster communication. Probably XPC is the answer. But not sure how to use XPC between two process which are written in different language. Any sample code would be great help.

Probably XPC is the answer. But not sure how to use XPC between two process which are written in different language.

That shouldn’t be a problem. One thing to keep in mind is that XPC has two APIs:

  • The low-level API

  • Foundation’s NSXPCConnection

You can’t mix these two on different side of the same XPC connection. My understanding is that Go has very poor integration with Objective-C, and thus you’ll want to use the low-level API at both ends.

Any sample code would be great help.

I’m not aware of any specific sample code for the low-level API, but if you search the ‘net for xpc_connection_create_mach_service you’ll find a bunch of code using it. A rich source of such examples is the Darwin open source.

Share and Enjoy

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

Communication between two process in macOS.
 
 
Q