WiseCleaner Think Tank
Encounter difficult computer problems?
All about maintenance and optimization of your Windows System.
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.
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.
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.
Prepare your icon file in PNG format (1024*1024 pixels is recommended) with a transparent background.
#!/bin/bash# Auto-generate icon.icns from icon.png (1024x1024)ICON_NAME=iconICONSET_NAME=${ICON_NAME}.iconsetICNS_NAME=${ICON_NAME}.icnsif [ ! -f ${ICON_NAME}.png ]; thenecho "Please put ${ICON_NAME}.png in the current directory."exit 1fimkdir -p $ICONSET_NAMEsips -z 16 16 ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_16x16.pngsips -z 32 32 ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]sips -z 32 32 ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_32x32.pngsips -z 64 64 ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]sips -z 128 128 ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_128x128.pngsips -z 256 256 ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]sips -z 256 256 ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_256x256.pngsips -z 512 512 ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]sips -z 512 512 ${ICON_NAME}.png --out ${ICONSET_NAME}/icon_512x512.pngsips -z 1024 1024 ${ICON_NAME}.png --out ${ICONSET_NAME}/[email protected]iconutil -c icns $ICONSET_NAMErm -rf $ICONSET_NAMEecho "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.
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.
On your Desktop, right-click and create two folders: dmg-temp and dmg-final.
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.
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.
hdiutil create -srcfolder ~/Desktop/dmg-temp -volname WiseX -fs HFS+ -format UDRW ~/Desktop/WiseX.dmg
Double-click WiseX.dmg to mount it.
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
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.
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.
wisecleaner uses cookies to improve content and ensure you get the best experience on our website. Continue to browse our website agreeing to our privacy policy.
I Accept