概要
- create-dmg/create-dmgを使って、下記のような構成のdmgを作成する。
参考
- create-dmg/create-dmg
- 決まったフォーマットのdmgならこれもあり?(私自身は試してないです)
実践
前提
- create-dmg/create-dmgの通りに進めていけばOK。
- またフォルダ構成は下記とする。
-
seticon.swift
に関しては後述。
-
Homebrewでインストール
brew install create-dmg
create-dmgの実行
-
--hide-extension
は動作していない?
cd /Users/ikeh/Downloads/DMG_Test
create-dmg \
--volname "Application Installer" \
--background "installer_background.jpg" \
--window-pos 200 120 \
--window-size 812 542 \
--icon-size 100 \
--icon "QuickImageUploader.app" 200 190 \
--hide-extension "QuickImageUploader.app" \
--app-drop-link 600 185 \
"Application-Installer.dmg" \
"source_folder/"
dmgのアイコン設定
- 私の環境では
--volicon
が動作していないように見えた。
https://github.com/create-dmg/create-dmg/blob/master/README.md
--volicon : set volume icon
- 代わりに下記の
seticon.swift
でアイコンを設定できる
swift seticon.swift Icon_1024px.png Application-Installer.dmg
Set Application-Installer.dmg icon to Icon_1024px.png [(1024.0, 1024.0)]
seticon.swift
import Foundation
import AppKit
// Apple deprecated their command line tools to set images on things and replaced them with a
// barely-documented swift function. Yay!
// Usage: ./seticon /path/to/my.icns /path/to/some.dmg
let args = CommandLine.arguments
if args.count != 3 {
print("Error: usage: ./seticon /path/to/my.icns /path/to/some.dmg")
exit(1)
}
var icns = args[1]
var dmg = args[2]
var img = NSImage(byReferencingFile: icns)!
if NSWorkspace.shared.setIcon(img, forFile: dmg) {
print("Set \(dmg) icon to \(icns) [\(img.size)]")
} else {
print("Setting icon failed, don't know why")
exit(2)
}
マウント時にフォルダを開く設定について
- 最近まで
bless
があったが、現在はdeprecatedになっている。 - またこのオプションを指定しなくても以前通り自動でフォルダは開くみたい。
https://github.com/create-dmg/create-dmg/blob/master/README.md
--bless: bless the mount folder (deprecated, needs macOS 12.2.1 or older, #127)
https://github.com/create-dmg/create-dmg/issues/127
I'm updating to 12.3 to test that one. Just checked that not using that option does not seem to affect on the DMG opening in the Finder when mounted.