Amazing.
I wanted to upgrade my privileged helper form SMJobBless to SMAppService.daemon.
Read the existing code from UpdatingYourAppPackageInstallerToUseTheNewServiceManagementAPI, ok it was nice and simple.
Well I wanted to do a bit more, after all apple tells me SMJobBless is deprecated and I should look into the SMAppService class
So I made this change
class func register() {
let service = SMAppService.daemon(plistName: "com.xpc.example.agent.plist")
do {
try service.register()
print("Successfully registered \(service)")
} catch {
print("Unable to register \(error)")
exit(1)
}
}
Made sure to have the plist under $APP.app/Contents/Library/LaunchDaemons/com.xpc.example.agent.plist
Boom, I immediately hit the wall. Apple sends me a not so useful error
Unable to register Error Domain=SMAppServiceErrorDomain Code=3 "No such process" UserInfo={NSLocalizedFailureReason=No such process}
Common guys, instead of riddles, give us better examples, more examples, that cover more than 1% of the functionality.