views:

342

answers:

5

What's the preferred way to create a distributable file for Mac OS: dmg or pkg?

+1  A: 

Disk image if installing is as simple as drag-and-drop, package installer if you need to install supporting files outside of the app bundle.

Also note that with a disk image, it's a good idea to offer to install the app for the user if they run the program from the image. Otherwise some people will never actually install the program and just keep the disk image around forever.

Chuck
+4  A: 

I don't think there's a fixed answer. If you just have an application bundle, I think most end-users expect a DMG. But if you're installing a menu extension -- or anything else that would need to be in a Library directory, you'll usually need a pkg file.

I've used both for different types of installs. They both work. As long as you use one of these two (and not some type of wacky install script), people will be happy IMHO.

Geoff Hutchison
Realistically, preference panes don't need any installers; if there's a pref pane on a disk image, and the user double-clicks it, OS X is smart enough to know that it needs to be installed, and even asks the user if it should be installed for *all* users or just the account logged in (/Library/Preference Panes/ or ~/Library/Preference Panes/).
delfuego
I agree with your comment. But let's be realistic that many of these do include installers. I'll edit my response -- I was trying to think of things which need PKGs.
Geoff Hutchison
A: 

The trend for Mac apps is a nice DMG with a drag-installable application on it. Or maybe even just a ZIPped application that knows how to copy itself to the user's Applications directory when launched.

Don't use an installer unless you absolutely have to.

Sixten Otto
+1  A: 

Advantages of zips:

  • Safari auto-unzips
  • Easy to create
  • Easier to use with Sparkle updater

Advantages of dmgs:

  • Can be used to display a license aggrement
  • Can display install instructions (DMG Canvas)

Don't use .pkgs unless you need to place your bundle in a certain location. (WebKit bundles, Kernel extensions...)

weichsel
+5  A: 

Regarding the disk image (DMG) approach, typically this is implemented in a way that makes obvious to the user that they need to drag the app over to their /Applications folder. (Sometimes this is done with a pre-existing alias of the /Applications folder next to the app icon on the DMG, and then a background image that has an arrow between them or text instructions overlaid that explains what to do.) Too often, though, users just double-click the app and run it from the disk image, which gets confusing (what if they eject the disk image? what happens next time they try to run the app?)

Alexander Limi, one of the Mozilla Firefox developers, has two great articles about getting your OS X app to detect when it's being run from the installer disk image, and then offering to copy itself to the /Applications folder.

It's an approach that's now accepted enough to have generated at least one code class, M3InstallController, to enable the behavior in your own app. The developer of another OS X app that takes this approach released his own code example, as well.

So if you go the route of a disk image with an app that needs to be dragged into the /Applications folder, strongly consider detecting whether the user is running the app from the disk image, and offer to move it for them! Your users, and your support folks, will thank you. :)

delfuego