Hey Quinn,
I dont think I was clear regarding my implementation of the daemon. So I am attaching a link to the code. Its super small and easy to go through. Please have a look. I still have a few questions-
1. XPC Lifecycle
My Golang daemon is continuously running in the background. I added <key>MachServices</key> field in my daemon's plist file to use XPC. I have C code that contains XPC logic, which I call from Golang(using Cgo).
My question: In my implementation I am using Golang to call C code, how is the XPC lifecycle affected by this? Is the XPC listener launched on demand, or does it stay running as long as the daemon?
2. freeing up variables
I am using dispatch_resume that doesnt return, so how can I free the dispatch source, queue and the XPC connection object variables ?
3.
Your daemon is managed by launchd and that owns the named XPC endpoint.
Do you mean launchd owns the endpoint?
4.
The ideal pattern is for your daemon to support transactions.
Do you mean using xpc_transaction_begin and xpc_transaction_end?