Creating nice dmg “installer” for Mac OS X

后端 未结 6 1612
深忆病人
深忆病人 2020-12-22 15:59

I\'ve made my first Qt application for Mac OS X. Now I want to create nice .dmg file that will allow user to easily install it. I am thinking about something like firefox ha

6条回答
  •  隐瞒了意图╮
    2020-12-22 16:32

    You can do that with Finder:

    1. Download and unzip this empty DMG file (I'm the one who created and uploaded it)
    2. Resize the DMG file to the appropriate size (the appropriate size is usually its current size plus the size of your .app file). To do this, open the disk utility (if you don't know how to do this, search for disk utility in Launchpad). Then click on "Images" in the menu bar and choose "Resize...". You will get a window to open a file, open the empty DMG file.
    3. Double-click on the DMG file to mount it. A device on the desktop named Untitled should appear. Rename it to the name that you want (you probably want to give it the same name as your program).
    4. Open that device. You should see something like this:

      If everything is white except the shortcut to the Applications folder, press Cmd+J and a window will be opened. On the bottom of that window, there is a square with the label "Drag image here". Click on that square and an Open dialog will open. In that dialog, press Cmd+Shift+G and type /Volumes/(whatever you called the device in step 3)/.image and select image.png.

      Everything here except the shortcut to the Applications folder is just a background image. You might want to change the background image (which contains the background color and the arrow). To do so, open the file /Volumes/(whatever you called the device in step 3)/.image/image.png in an image editor and edit it to whatever you want. After you've done this, you might need to unmount the device and remount it by opening the DMG file to see the changes. Depending on what you put in the image, you might also need to move the shortcut to the Applications folder around to fit the new background image.

    5. Drag your .app file to the beginning of the arrow in the window where the device from the DMG file is opened so that it looks like this:

      You might get an error saying that there isn't enough free space. If that's the case, go back to step 2 and resize the DMG file to a larger size.

    6. Unmount the device by clicking on the arrow next to the device name in Finder:

    7. Convert the DMG file to read only. To do this, open the terminal and type this (replace /path/to/dmg/file by the path to the DMG file and nameOfDmgFile.dmg by the name of the DMG file):

      cd /path/to/dmg/file
      hdiutil convert -format UDZO -o newNameOfDmgFile.dmg nameOfDmgFile.dmg
      

      This will create a new DMG file called newNameOfDmgFile.dmg (or whatever other name you used above), which is the file that you want.

提交回复
热议问题