Uninstaller for a cocoa application

前端 未结 2 1421
滥情空心
滥情空心 2021-02-06 15:44

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 pro

2条回答
  •  萌比男神i
    2021-02-06 15:56

    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:

    
    
    
    
    Label
    com.your.app
    WatchPaths
    
        ~/.Trash
    
    ProgramArguments
    
        osascript
        /path/to/your/app/Check Trash.applescript
    
    KeepAlive
    
    

    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

提交回复
热议问题