Search code examples
macoscocoalaunchd

Clean up LaunchAgents on Uninstall


I have a LaunchAgent in my Mac OSX app.
How do I clean up the Launch Agent plist file when a User drags my app into the trash to uninstall? Can I make a symbolic link to a plist file in my bundle or something like that?


Solution

  • As Joshua Nozzi commented, there's no way to be notified when the user trashes your app. That doesn't completely shut you out of cleaning up launchd tasks, though. If any of those tasks run an executable or shell script outside of your app (if not, they could), said script can check to see whether the app is still installed and unschefule/delete itself if not.