Hi there :)
I try to put an Xcode project in place within a LaunchAgent.
The ultimate goal is to have an "application" with two component:
- macOS application with just an basic UI
- all the logic happens in a LaunchAgent that runs on background and is launch at startup.
The macOS app uses XPC to send messages to the agent that will run either the app is opened or not.
I struggled at first having this error (for the agent):
An XPC Service cannot be run directly.
Then I found using MachServices
key in the .plist
of the agent fixes the issue, plus:
let listener = NSXPCListener.init(machServiceName: "com.tonygo.NetworkMonitorAgent")
Then I wonder:
- Do we have somewhere a documentation about how to setup a LaunchAgent in Xcode
- I create the plist of the agent on side and run it manually, I could do this in a more automatic way
- How could I package a macOS applciation that will contains the agent, install it and load the agent?
Note: This is mainly for learning and understanding what we could do at each level (XPCService, LaunchAgents, LaunchDaemon, etc.).