Making an Uninstaller.

Discussion in 'Mac Programming' started by BlindSoul, Dec 25, 2011.

  1. macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #1
    Hello,

    I am interested in making an Uninstaller for my Mac application.
    Does anyone have a simple guide to make one? even a Javascript uninstaller can be good?


    Thank you very much!
     
  2. macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    Tell us about your application.

    Does it consist of a single Application bundle, or, are there multiple files spread about the system?
     
  3. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
  4. macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #4
    If it's simply a couple of application bundles I don't believe you should bother with either a installer, or a uninstaller.

    The user only need remove the application bundles, a preference file, and it's gone. This is normal for the platform.

    Don't make it more work than is necessary.
     
  5. macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #5
    Best advice I can give you is to use the Apple developer tools' PackageMaker (/Developer/Applications/Utilities/PackageMaker), make a .pkg file for your application.

    Once that's done, you can probably make an uninstaller using a shell script (that will get installed with your app) or a third application which will read in the contents of your package's Receipt (/Library/Receipts) file to know what to remove from the system.
     
  6. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #6
    I should have an Uninstaller because one of the files are hidden.
    I have a .pkg of Installation but how do I make a .shell file? What do I write in it? and where do I place it?
     
  7. subsonix, Dec 26, 2011
    Last edited: Dec 26, 2011

    macrumors 68040

    Joined:
    Feb 2, 2008
    #7
    You can create a uninstall script in any language. All you need to do is delete all files that belongs to the application. You could also potentially add an uninstall option as a menu post in the application itself. Same principle, delete all files that belongs to the application including the app itself and quit.

    Package maker has a command line utility, that might be useful for your purpose, particularly the --forget option. There is also an unlink option, but it's apparently not safe to use and rely on, on it's own. More info about this at the pkgutil manpage: http://developer.apple.com/library/...Darwin/Reference/ManPages/man1/pkgutil.1.html
     
  8. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #8
    I really have no clue what you just said, but thanks!
     
  9. macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #9
    A shell script is just that, a script written in a shell scripting language. On Mac, the bourne shell is the best candidate since you're guaranteed it will be there.

    Place it with your application. Though as subsonix says, you could always just place a uninstall option in the root menu of your application and write your uninstall routine in Objective-C by reading in the receipt and using that information and your app's state to uninstall.
     
  10. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #10
    It's very good you guys say how it works and everything, but I need something simple. Some simple guide, Step by step. I am very noob in all these things, I never used xCode. I just used Composer to make my Installer.

    So if anyone can guide me step by step, or send me an example and I will just edit it it would be great.

    Thanks!
     
  11. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #11
    Is there a reason you need to make the hidden .app bundle external to the visible .app bundle?
     
  12. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #12
    Yes, the external .app requires the other .app which is hidden because there's no reason for people to use it.
     
  13. macrumors 603

    Joined:
    Aug 9, 2009
    #13
    I think Sydde's point was "Why don't you just embed the hidden app within the visible app?". An app-bundle can contain other executables, including complete other app-bundles.

    If the hidden app is embedded in the visible app, then for users, it appears to be a single app. They can move it, delete it, etc. and never lose the hidden app, because it's embedded in the visible app bundle.

    Also, by embedding the hidden app, the visible app always knows exactly where to find the hidden app: in its own app bundle.

    I can't immediately think of an example of an app bundle embedded in another app bundle. However, if you look inside Activity Monitor.app, located in the standard /Applications/Utilities folder, you'll see two executables. One is the privileged data-collection daemon.
     
  14. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #14
    That's a great idea, I think it would be the best thing to do, though I don't know how to do that... I really have no skills in xCode or such, It feels like chinese to me.
     
  15. macrumors G4

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #15
    How are you creating both .app bundles? If you're using a packager outside of Xcode, such as py2app/PyInstaller (Python), Jar Bundler (Java), or some other packager, the solution involves modifying how the first .app loads its resources, by altering the resource search path.

    There are several ways of doing this, but the exact method is going to depend on your packager and programming language. An example is provided, for Java applications packaged with Jar Bundler:
    Code:
    if (new File("../../MacOS/JavaApplicationStub).isExecutable()) {
        // We are inside a Mac OS X-style application package
        // Load the embedded application
        Runtime.getRuntime().exec("../SecondApp.app/Contents/MacOS/SecondApp");
    }
    
     
  16. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #16
    To make the Installer I've used JAMF Composer.
     
  17. macrumors 603

    Joined:
    Aug 9, 2009
    #17
    JAMF Composer only makes installers. It doesn't make the apps to install.

    How did you make the actual apps? The reason we're asking is because you said you didn't use Xcode.

    We're now back again to post #2: Tell us about your applications.
    This time, please provide more specific information on how you wrote it, in what language, using what tools or IDE.
     
  18. thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #18
    The hidden application is Prism, an Application which creates webApp into Mac Application, then I made my installer to install Prism and my webApp created with Prism, and that's why I need both cause else my webApp won't load.
     

Share This Page