WiseCleaner Think Tank

Encounter difficult computer problems?
All about maintenance and optimization of your Windows System.

Home > Think Tank > How to Create a DMG File for .app on Mac

How to Create a DMG File for .app on Mac

Jul 14, 2025

Creating a professional DMG file for your Mac application not only makes installation easier for your users but also adds a polished touch with custom branding, security, and convenience. In this guide, we’ll walk you through the step-by-step process to create a DMG file for .app on Mac using only the command line, without any third-party tools. This includes how to add a custom icon, set up your folders, and ensure your DMG file is secure for distribution.

What is a DMG file?

A DMG file is a disk image format commonly used on macOS to distribute software and files. It acts like a virtual disk, allowing users to mount and access its contents as if they were on a physical drive. DMG files are often used for application installers because they can be compressed, encrypted, and made read-only, providing both security and convenience for software distribution.

Steps to Create a DMG File

Step 1: Prepare Your Custom Icon

Adding an ICNS file is not strictly required, but it gives your DMG a custom, branded icon when mounted. This makes your installer look more professional, reinforces your brand, and creates a better first impression for users.

1. Get an Icon

Prepare your icon file in PNG format (1024*1024 pixels is recommended) with a transparent background.

2. Generate ICNS File

#!/bin/bash
# Auto-generate icon.icns from icon.png (1024x1024)
ICON_NAME=icon
ICONSET_NAME=${ICON_NAME}.iconset
ICNS_NAME=${ICON_NAME}.icns
 
if [ ! -f ${ICON_NAME}.png ]; then
  echo "Please put ${ICON_NAME}.png in the current directory."
  exit 1
fi
 
mkdir -p $ICONSET_NAME
sips -z 16 16     ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_16x16.png
sips -z 32 32     ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]
sips -z 32 32     ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_32x32.png
sips -z 64 64     ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]
sips -z 128 128   ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_128x128.png
sips -z 256 256   ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]
sips -z 256 256   ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_256x256.png
sips -z 512 512   ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]
sips -z 512 512   ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_512x512.png
sips -z 1024 1024 ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]
iconutil -c icns $ICONSET_NAME
rm -rf $ICONSET_NAME
echo "ICNS file created: ${ICNS_NAME}"

chmod +x make_icns.sh
./make_icns.sh

Then the file Icon.icns will be generated in the same folder.

create volumeicon.icns

Step 2: Organize Your Folders

Organizing all necessary files into a dedicated folder ensures that your DMG package is tidy and user-friendly. This approach not only helps users find everything they need quickly but also minimizes installation errors and enhances the overall professionalism of your app distribution.

1. Create Folders

On your Desktop, right-click and create two folders: dmg-temp and dmg-final.

2. Prepare the Applications Alias

3. Copy .app

4. Add the Custom Icon

cd ~/Desktop/dmg-temp
mv VolumeIcon.icns .VolumeIcon.icns
setfile -a CV .VolumeIcon.icns

You may need to install Xcode Command Line Tools to use setfile.

Step 3: Create the DMG File

First, create a writable DMG from your prepared folder so you can make final adjustments, such as customizing the layout or adding icons. Once everything looks right, convert it to a compressed, read-only DMG to ensure your installer is secure, professional, and ready for distribution.

1. Open Terminal to create a writable DMG:

hdiutil create -srcfolder ~/Desktop/dmg-temp -volname WiseX -fs HFS+ -format UDRW ~/Desktop/WiseX.dmg

create writable dmg

2. Mount the DMG

Double-click WiseX.dmg to mount it.

3. Apply the Custom Icon

4. Finalize & Compress the DMG

Open Terminal, and convert the DMG to a compressed, read-only format for release.

hdiutil convert ~/Desktop/WiseX.dmg -format UDZO -o ~/Desktop/dmg-final/WiseX-final.dmg

create compressed read only dmg

Step 4: Add Security with SHA256 Checksum

Adding a security checksum to your DMG file is important because it verifies the integrity of your installer, reassuring users that the file hasn’t been tampered with and ensuring a safe installation process.

Open a terminal and run the following command to generate a SHA256 checksum to verify the integrity and authenticity of the DMG file.

shasum -a 256 ~/Desktop/dmg-final/WiseX-final.dmg

Then publish the checksum alongside your DMG so users can confirm it hasn’t been tampered with.

Bottomline

Creating a custom DMG file on Mac is a straightforward process that ensures your application looks professional and is secure for your users. By following these steps, preparing a custom icon, organizing your folders, creating and customizing the DMG, and adding a security checksum, you'll deliver a polished installation experience that builds trust and reinforces your brand. Whether you're a developer or a tech enthusiast, mastering DMG creation is a valuable skill for Mac software distribution.

Reference Documents

Apple's official HDIUtil command manual

10