I know it's uncommon for Mac apps to have uninstallers. But in our use-case, we need to have a separate uninstaller app for various purposes, including:
- to prompt the user for some information before deleting the app
- to stop the app (which is kept running via launch agent with KeepAlive = TRUE), so technically this is to unload or bootout the launch agent (and delete it's plist from ~/Library/LaunchAgents/)
- to remove the main app from the /Applications folder (and ofcourse removing its extensions, but I assume that is automatic)
- to remove the artifacts that the app has created outside it's container
Please note that the main app is sandboxed, signed by developer id, and contains system extensions.
I've took a look at a couple of other third party apps (eg. AWS VPN Client), which also have a separate uninstaller app. When run, it asks for system admin credentials before proceeding, and then clean up things as expected.
The question is: What is the 'right' way (best practices, APIs, pitfalls etc) to build such an uninstaller app that can do all of the above ?