Skip to content

Instantly share code, notes, and snippets.

@jadeatucker
Last active April 10, 2024 19:49
Show Gist options
  • Save jadeatucker/5382343 to your computer and use it in GitHub Desktop.
Save jadeatucker/5382343 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 #Disk Utility Type Disk Utility into Spotlite CMD+SPACEBAR from Finder or from Terminal:

open /Applications/Utilities/Disk\ Utility.app/

File -> New -> Disk Image from Folder or CMD+SHIFT+N

Select the folder myapp.app/ when prompted then click Image.

In the Save As field enter a name for the file like myapp.dmg.

From the Image Format drop-down select read/write then click Save.

#Edit Folder Preferences Mount the dmg and open it by double-clicking the file in Finder or from Terminal:

open myapp.dmg
open /Volumes/myapp/

Create a link/shortcut to /Applications folder by right-clicking on the Applications folder and selecting Make Alias then drag it into the dmg folder or from Terminal:

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

In Finder press CMD+1 to switch to icon view and arrange icons as needed.

Press CMD+J to show the View Options window and adjust view settings as needed.

From Background: section choose Picture then Drag and drop the image you want to use as the background where it says Drag image here.

Unmount/Eject the dmg when finished with View Options or from Terminal:

umount /Volumes/myapp/

#Compress and convert to Read-only From Disk Utility right-click on myapp.dmg disk image and select Convert "myapp.dmg".

In the Save As field enter a new name for the file like myappfinal.dmg.

From the Image Formate drop-down select read-only then click Save or from Terminal:

hdiutil convert -format UDZO -o myappfinal.dmg myapp.dmg

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

@ThaNerd
Copy link

ThaNerd commented Nov 19, 2016

Great! I wish there was an application to make these in a more pixel-perfect way, but I guess eye-balling the position of icons should be right...
Thanks for writing this complete guide!

@Jusung
Copy link

Jusung commented May 28, 2017

What a great tutorial for creating a "DMG Installer"!
Thank you so much @jadeatucker!

@hellais
Copy link

hellais commented Jun 25, 2017

When searching for a solution for this I found this: https://github.com/andreyvit/create-dmg. It works well.

@peterng014
Copy link

Great! Thank you very much.

@PeterKaminski09
Copy link

This tutorial could use some updates. Not a lot of success using this with High Sierra.

@ppwfx
Copy link

ppwfx commented Nov 4, 2017

@PeterKaminski09 did you find out how to do it for High Sierra?

@pierow2k
Copy link

Fantastic! Thank you

@maxwell108
Copy link

Just add. . . if you want the DMG portable the background image needs to be in that initial folder and .invisible

@dieza
Copy link

dieza commented May 18, 2018

In High Sierra, I got trouble with the umount part and error like resource temporarily unavailable, I try detach with no success but after a reboot the last part hdiutil convert -format UDZO -o myappfinal.dmg myapp.dmg goes fine.

@WifiRouterYT
Copy link

Thank you! I've been waiting to learn this for a long time!

@jjsjjs
Copy link

jjsjjs commented Apr 21, 2019

this sentence is not clear on what you exactly mean: Create a link/shortcut to /Applications folder by right-clicking on the Applications folder and selecting Make Alias then drag it into the dmg folder or from Terminal:
Which /Applications folder are you refering to? The source folder or the destination folder?
Drag what to the DMG the source applications folder or the Alias? When i do the alias nothing happens.
PLease clarify thanks!

@minhazpanaraEI
Copy link

Awesome... Thank you!

@sweatyc
Copy link

sweatyc commented Aug 20, 2019

Thank for you this hint and it really help!

One thing I wanted to point out, instead of using umount /Volumes/myapp/, its better to use hdiutil detach /Volumes/myapp.

I tried to use umount but it only unmount the image but still seeing the Apple read/write Media in Disk Utility, which I still need to manually click to detach it.

@s3hMC
Copy link

s3hMC commented Aug 28, 2019

this sentence is not clear on what you exactly mean: Create a link/shortcut to /Applications folder by right-clicking on the Applications folder and selecting Make Alias then drag it into the dmg folder or from Terminal:
Which /Applications folder are you refering to? The source folder or the destination folder?
Drag what to the DMG the source applications folder or the Alias? When i do the alias nothing happens.
PLease clarify thanks!
Hi,
I don't completely understand your question, but to simplify what the sentence says:

  1. Find your "Applications" folder. This is the folder on your computer that stores all of your apps. You can find this folder by following these instructions
  2. Right click on it, and find the option that says "Make Alias"
  3. Take the alias and move it into the disc/dmg folder
    Hope this helps!

@AegerBorder
Copy link

I love you. Simple as that. Worked great, went fast, all happy :D

@BlindMan64
Copy link

BlindMan64 commented Mar 25, 2020

Using macOS Catalina 10.15.3 + Disk Utility version 19.0

Trying to create dmg for '/Users/me/Desktop/myapp.app' folder.

In Disk Utility
File - New Image - Image from Folder
I can select Desktop but myapp.app folder is greyed out and cannot be selected.

Tried chmod 777 myapp.app but that did not help.

Advice greatly appreciated.

@cvl
Copy link

cvl commented Apr 10, 2020

The background is not visible on another computer (just the one on which the dmg was created).

@sysulzh
Copy link

sysulzh commented Apr 14, 2020

Using macOS Catalina 10.15.3 + Disk Utility version 19.0

Trying to create dmg for '/Users/me/Desktop/myapp.app' folder.

In Disk Utility
File - New Image - Image from Folder
I can select Desktop but myapp.app folder is greyed out and cannot be selected.

Tried chmod 777 myapp.app but that did not help.

Advice greatly appreciated.

Hey @BlindMan64, I found the same issue. Solved it by creating a directory to hold the app.

@BlindMan64
Copy link

Hey @BlindMan64, I found the same issue. Solved it by creating a directory to hold the app.

Thanks @sysulzh.

'/Users/me/Desktop/myapp/myapp.app' allowed me to create dmg for '/Users/me/Desktop/myapp/'.

I also used https://www.araelium.com/dmgcanvas which made creation of dmg very easy.

@acswift
Copy link

acswift commented Apr 12, 2021

Just a note that your markdown titles are not showing up correctly because there are spaces missing after the pound signs.

Otherwise, very helpful. I really appreciate your publishing this document.

@insha
Copy link

insha commented Sep 14, 2022

The DropDMG app is one of the best ways (I have personally used it for a long time) for creating dmg files for this purpose and in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment