What I did.
-
Started with the example at https://developer.apple.com/documentation/servicemanagement/updating-your-app-package-installer-to-use-the-new-service-management-api
-
Changed it to configure a system daemon instead
let service = SMAppService.daemon(plistName: "com.xpc.example.daemon.plist")
- Disabled automatic register in the package
postinstall
script (or else pkg install fails) - Built/Installed the package, it just places files in the disk
- Validated install files
- Ran the test|register commands by hand
sudo ../SMAppServiceSampleCode.app/Contents/MacOS/SMAppServiceSampleCode" register
-
Dealt with System Settings user interaction to do this
-
Validated that
com.xpc.example.daemon
is installed and ready to work -
sudo launchctl list | grep example
-
sudo launchctl print system/com.xpc.example.daemon
-
Got it to successfully do some work, YAY
sudo ../SMAppServiceSampleCode.app/Contents/MacOS/SMAppServiceSampleCode" test
Expectations
My users would obviously download and install this pkg, so to make it easy for them. I would expect that I could call
SMAppService.daemon(plistName: "...")
.register()
during the package postinstall
installation step and the system daemon would be configured.
Observations
After getting all my teeth pulled why can't I just do that?
Why so many hurdles for the dev and the end user, asking them to code sign this and that, notarize this and that, click here and there, accepting this and that?
I understand the job of a developer but for the end user this should be relatively easy.
Questions
Do I need to start a DTS ticket to get this simple flow to work? It could be I'm missing step 42 in my endeavor :-)