Skip to content

Instantly share code, notes, and snippets.

@saravanabalagi
Forked from jadeatucker/HOWTODMG.md
Last active April 14, 2020 14:29
Show Gist options
  • Save saravanabalagi/0f031a436cdaebb36363c76b82643ac3 to your computer and use it in GitHub Desktop.
Save saravanabalagi/0f031a436cdaebb36363c76b82643ac3 to your computer and use it in GitHub Desktop.
How to create a "DMG Installer" for Mac OS X

Creating a DMG installer for OS X

A DMG Installer is convenient way to provide end-users a simple way to install an application bundle. They are basically a folder with a shortcut to the Applications directory but they can be customized with icons, backgrounds, and layout properties. A DMG file (.dmg) is a Mac OS X Disk Image file and it is used to package files or folders providing compression, encryption, and read-only to the package.

Creating the DMG file

  1. Create a new folder and place your .app inside it
  2. Type Disk Utility into Spotlight cmd space from Finder
  3. File > New > Disk Image from Folder (or press cmd shift< kbd>n) and pick this folder inside which your app resides
  4. File > Save As and save it as myapp.dmg in Documents with read/write

Editing the DMG

  1. Mount myapp.dmg
  2. Right Click Applications folder and select Make Alias
  3. Move Applications shortcut inside the mounted disk image
  4. Create .background folder inside the image and place your background image (500x320) here
  5. Open View Options on the root of the disk image, select Picture for Background and drag the image inside the .background folder to set the background
  6. Arrange icons as needed to align with the background (Tip: Use cmd 1 for icon view)
  7. Finally, eject/unmount the image.

Compress and convert

  1. Open Disk Utility, then Images > Convert and select myapp.dmg
  2. File > Save As and save as myapp_final.dmg in Documents with read-only

Verify

Congratulations you are finished! Mount the new dmg to verify it is working properly.

Terminal Commands

open /Applications/Utilities/Disk\ Utility.app/
# Save as dmg and then
open ~/Documents/myapp.dmg

open /Volumes/myapp/
cd /Volumes/myapp/
ln -s /Applications Applications

# Create .background, copy image and Set background
# Arrange and Adjust Icons
umount /Volumes/myapp/

hdiutil convert -format UDZO -o ~/Documents/myapp_final.dmg ~/Documents/myapp.dmg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment