There are two main applications for compressing your application: Disk Utility (or Disk Copy in older versions of Mac OS X) and PackageMaker. Disk Utility allows you to create compressed disk images, while PackageMaker creates packages that can be installed using the Mac OS X installer.
The recommended form of application distribution is a compressed disk image. A compressed disk image preserves resource forks that may be present, allows drag-and-drop installation, allows license display, and even allows encryption of data, if required.
If your application is a single application bundle, simply put it and any relevant documentation on a disk image with Disk Utility, then compress it and distribute it.
If you have an application that requires administrator privileges to install into privileged directories or requires more than a simple drag-and-drop installation, use PackageMaker (/Developer/Applications/PackageMaker) to build installer packages for Apple’s Installer application.
The basics of using Disk Utility to make a disk image are given in the next section. For help using PackageMaker, choose PackageMaker Help from the PackageMaker Help menu.
The following steps help you package your application as a disk image (.dmg file) for distribution on Mac OS X.
Open /Applications/Utilities/Disk Utility.app by double-clicking it.
From the Image menu, choose New Blank Image. Disk Utility opens a new window with customization options as in Figure 8-1.
In the “Save as” text box, enter the name of the compressed file that you will distribute. By default, a.dmg suffix is appended to the name you enter. Although it is not required, it is a good idea to retain this suffix for clarity and simplicity.
In the Volume Name text field, enter the name of the volume that you want to appear in the Finder of a user’s computer. Usually this name is the same as the name of the compressed file without the .dmg suffix.
In the file browser, set the location to save the file on your computer. This has nothing to do with the installation location on the end user’s computer, only where it saves it on your computer.
Set the Size pop-up menu to a size that is large enough to hold your application.
Leave the Format set to Mac OS Extended (the HFS+ file format).
Leave Encryption set to none. If you change it, the end user must enter a password before the image can be mounted, which is not the normal way to distribute an application.
Click Create.
Once you have a disk image, mount it by double-clicking it. You can now copy your files to that mounted image. When you have everything on the image that you want, you should make your image read-only. Again from Disk Utility, perform these steps:
Unmount the disk image by dragging the volume to the Trash, clicking the eject button next to the device in a Finder window, or selecting the mounted volume and choosing Eject from the Finder’s File menu.
Choose Convert Image from the Image menu.
In the file browser, select the disk image you just modified and click Convert.
Choose a location to save the resulting file, change the image format to read-only, and click Convert.
You now have a disk image for your application that is easy to distribute.
Last updated: 2008-04-08