问题
I am using PackageMaker for the installer of my application (which is more than a simple bundle). I am wondering how to create an uninstaller, where to install it and how to provide to the user a way to launch it.
Thanks in advance for your help,
回答1:
While implementing an uninstaller for some MAC OS application, we've come up with an idea. As SerpicoLugNut says:
Seriously - 98% of Mac apps don't offer an uninstaller, and if most people want the app uninstalled, they will just drag the app to the trash
We deviced that we can watch the Trash, and in case our application appears in the Trash, we can ask a user if he/she wants to uninstall it.
Fortunately, the MAC OS provides an out-of-box functionality to implement this. You just have to put the following .plist to the /Library/LaunchAgents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.your.app</string>
<key>WatchPaths</key>
<array>
<string>~/.Trash</string>
</array>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/path/to/your/app/Check Trash.applescript</string>
</array>
<key>KeepAlive</key>
<false/>
In this example, a Check Trash.applescript
is run once the user's Trash is modified. This script should check that your application is in the Trash and ask the user if he/she wants to proceed with the uninstall. Of course this can be an arbitrary script or even a binary executable, not only an applescript. For more information, look at the man page for launchd.plist
回答2:
There is no official un-installation method on OS X. There are apps that will take your app binary, and find the associated files it installs with it, and delete those as well, but apart from those, your only uninstallation options are:
1) Write your own uninstaller script.
2) Use an installer that features un-installation capabilities. I'm not familiar with what the VISE installer has to offer these days, but back in the early days, I remember it had un-installation capabilities.
3) Do what most applications do, and don't worry about un-installation. Seriously - 98% of Mac apps don't offer an uninstaller, and if most people want the app uninstalled, they will just drag the app to the trash, or (if they are slightly more savvy) use an uninstaller app like AppZapper or AppDelete.
回答3:
A solution would be to create a metapackage, don't add any packages to it, and then add a script to it that deletes the programs. Most applications on osx that need to be uninstalled with an uninstaller have a button that says "Uninstall Application" in the application or help menus
来源:https://stackoverflow.com/questions/4377015/uninstaller-for-a-cocoa-application