LoginSignup
0
0

More than 1 year has passed since last update.

create-dmgを使ったdmgの作成

Posted at

概要

image

参考

実践

前提

  • 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

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.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0