create-dmg/readme.md

79 lines
3.2 KiB
Markdown
Raw Permalink Normal View History

2021-01-02 05:56:37 +00:00
# create-dmg
2017-03-27 14:09:27 +00:00
2018-04-29 12:07:51 +00:00
> Create a good-looking [DMG](https://en.wikipedia.org/wiki/Apple_Disk_Image) for your macOS app in seconds
2017-03-27 14:09:27 +00:00
2017-03-31 14:19:57 +00:00
Imagine you have finished a macOS app, exported it from Xcode, and now want to distribute it to users. The most common way of distributing an app outside the Mac App Store is by putting it in a `.dmg` file. These are hard to create, especially good-looking ones. You can either pay for a GUI app where you have to customize an existing design or you can run some homebrewed Bash script and you still have to design it. This tool does everything for you, so you can play with your 🐈 instead.
2017-03-31 12:46:41 +00:00
<img src="screenshot-cli.gif" width="998">
2017-03-27 14:09:27 +00:00
*This tool is intentionally opinionated and simple. I'm not interested in adding lots of options.*
## Install
2018-04-29 12:07:51 +00:00
Ensure you have [Node.js](https://nodejs.org) 8 or later installed. Then run the following:
2017-03-31 13:59:29 +00:00
2017-03-27 14:09:27 +00:00
```
$ npm install --global create-dmg
```
## Usage
```
$ create-dmg --help
2018-04-29 12:07:51 +00:00
Usage
$ create-dmg <app> [destination]
2018-04-29 12:02:41 +00:00
2018-04-29 13:58:01 +00:00
Options
2020-02-19 11:28:18 +00:00
--overwrite Overwrite existing DMG with the same name
--identity=<value> Manually set code signing identity (automatic by default)
--dmg-title=<value> Manually set DMG title (must be <=27 characters) [default: App name]
2018-04-29 13:58:01 +00:00
2018-04-29 12:07:51 +00:00
Examples
$ create-dmg 'Lungo.app'
$ create-dmg 'Lungo.app' Build/Releases
2017-03-27 14:09:27 +00:00
```
## DMG
The DMG detects the minimum runtime of the app, and uses ULFO (macOS 10.11 or later) or UDZO as appropriate. The resulting image has the filename `App Name 0.0.0.dmg`, for example `Lungo 1.0.0.dmg`.
It will try to code sign the DMG, but the DMG is still created and fine even if the code signing fails, for example if you don't have a developer certificate.
2017-03-27 14:09:27 +00:00
2020-06-06 06:12:29 +00:00
**Important:** Don't forget to [notarize your DMG](https://stackoverflow.com/a/60800864/64949).
2017-03-27 14:09:27 +00:00
<img src="screenshot-dmg.png" width="772">
2020-02-19 11:28:18 +00:00
### Software license agreement
2020-02-19 11:28:18 +00:00
If either `license.txt`, `license.rtf`, or `sla.r` ([raw SLAResources file](https://download.developer.apple.com/Developer_Tools/software_licensing_for_udif/slas_for_udifs_1.0.dmg)) are present in the same directory as the app, it will be added as a software agreement when opening the image. The image will not be mounted unless the user indicates agreement with the license.
2020-02-19 11:28:18 +00:00
`/usr/bin/rez` (from [Command Line Tools for Xcode](https://developer.apple.com/download/more/)) must be installed.
2020-02-19 11:28:18 +00:00
### DMG icon
2019-05-12 16:44:54 +00:00
[GraphicsMagick](http://www.graphicsmagick.org) is required to create the custom DMG icon that's based on the app icon and the macOS mounted device icon.
#### Steps using [Homebrew](https://brew.sh)
2019-05-12 16:44:54 +00:00
```
$ brew install graphicsmagick imagemagick
```
2020-02-19 11:28:18 +00:00
#### Icon example
2019-05-12 16:44:54 +00:00
Original icon → DMG icon
<img src="icon-example-app.png" width="300"><img src="icon-example.png" width="300">
2020-02-19 11:28:18 +00:00
## Links
- [Product Hunt post](https://www.producthunt.com/posts/create-dmg)
## Related
- [Defaults](https://github.com/sindresorhus/Defaults) - Swifty and modern UserDefaults
- [LaunchAtLogin](https://github.com/sindresorhus/LaunchAtLogin) - Add “Launch at Login” functionality to your macOS
- [Preferences](https://github.com/sindresorhus/Preferences) - Add a preferences window to your macOS app
- [More…](https://github.com/search?q=user%3Asindresorhus+language%3Aswift)