I have been playing with application bundled LaunchAgents:
- I downloaded Apple sample code,
- Run the sample code as is,
- Tweaked the sample code a lot and changed the LaunchAgents IDs and Mach ports IDs,
- Created new projects with the learnings, etc.
After deleting all the Xcode projects and related project products and rebooting my machine several times, I noticed the LaunchAgent are still hanging around in launchctl
. If I write launchctl print-disabled gui/$UID
(or user/$UID
) I can see all my testing service-ids:
disabled services = {
"com.xpc.example.agent" => disabled
"io.dehesa.apple.app.agent" => disabled
"io.dehesa.sample.app.agent" => disabled
"io.dehesa.example.agent" => disabled
"io.dehesa.swift.xpc.updater" => disabled
"io.dehesa.swift.agent" => disabled
}
(there are more service-ids in that list, but I removed them for brevity purposes).
I can enable or disable them with launchctl enable/disable service-target
, but I cannot really do anything else because their app bundle and therefore PLIST definition are not there anymore. How can I completely remove them from my system?
More worryingly, I noticed that if I try to create new projects with bundled LaunchAgents and try to reuse one of those service-ids, then the LaunchAgent will refuse to run (when it was running ok previously). The calls to SMAppService
APIs such .agent(plistName:)
and register()
would work, though.
There’s a fundamental issue in play here: macOS doesn’t know whether an app has really been deleted. This results in a number of odd behaviours that regularly get noted here on the forums. You’ll find a good example here.
The calls to SMAppService APIs such .agent(plistName:) and register() would work
I’d like to clarify this:
-
Does “work” mean that they let you ‘resurrect’ these disabled jobs?
-
Or does it mean that the API calls work but don’t successfully get the jobs working again?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"