macOS 向けの配布物は 2 段構えです。実体は <productName>.app というアプリケーションバンドル(実はディレクトリ)で、これを Applications フォルダにドラッグさせるための入れ物が .dmg です。Tauri は tauri build で両方を生成します。ここでは .app の中身と bundle.macOS の設定、DMG の見た目の調整、Apple Silicon / Intel 両対応のユニバーサルビルドを扱います。
前提条件
- macOS 上でビルドすること(Windows / Linux からは作れません)
- Xcode Command Line Tools(
xcode-select --install) - ユニバーサルビルドをする場合は両アーキテクチャの Rust ターゲット
rustup target add aarch64-apple-darwin x86_64-apple-darwin
プラグインや capability の権限は不要です。
1. .app バンドルを作る
npm run tauri build -- --bundles app
src-tauri/target/release/bundle/macos/<productName>.app が生成されます。中身は次の構造です。
My Notes.app/
└── Contents/
├── Info.plist # バンドル ID・バージョン・最小 OS などのメタデータ
├── MacOS/my-notes # 実行ファイル本体
├── Resources/ # icon.icns と bundle.resources のファイル
└── Frameworks/ # bundle.macOS.frameworks で同梱したもの
bundle.macOS の主な設定
{
"bundle": {
"macOS": {
"minimumSystemVersion": "12.0",
"entitlements": "./Entitlements.plist",
"frameworks": ["CoreAudio", "./libs/libfoo.dylib"],
"files": { "embedded.provisionprofile": "./profile.provisionprofile" }
}
}
}
minimumSystemVersion: 既定は10.13。これより古い OS では起動時に非対応ダイアログが出るentitlements: サンドボックスやカメラ等の権限宣言。署名時に適用されるframeworks: システムフレームワーク名か.dylib/.frameworkのパス。Contents/Frameworks/にコピーされるfiles:Contents/からの相対パスをキーに任意のファイルを配置する
Info.plist に独自キー(NSCameraUsageDescription など)を足すには src-tauri/Info.plist を作ります。ビルド時に既定の内容とマージされるので、CFBundleIdentifier などの既定キーは書かないでください。
ユニバーサルバイナリ
npm run tauri build -- --target universal-apple-darwin
Apple Silicon と Intel の両方で動く 1 つの .app になり、出力先は target/universal-apple-darwin/release/bundle/ に変わります。サイズは約 2 倍になります。
2. DMG を作る
npm run tauri build -- --bundles dmg
src-tauri/target/release/bundle/dmg/<productName>_<version>_aarch64.dmg が生成されます。DMG を開いたときのウィンドウの見た目は bundle.macOS.dmg で調整します。
{
"bundle": {
"macOS": {
"dmg": {
"background": "./dmg/background.png",
"windowSize": { "width": 660, "height": 400 },
"appPosition": { "x": 180, "y": 170 },
"applicationFolderPosition": { "x": 480, "y": 170 }
}
}
}
}
background は「ここにドラッグ」の矢印を描いた PNG を windowSize と同じサイズで用意するのが定番です。appPosition と applicationFolderPosition はウィンドウ内の座標で、上の値が既定値です。
動作確認
open "src-tauri/target/release/bundle/macos/My Notes.app"
open src-tauri/target/release/bundle/dmg/My\ Notes_1.0.0_aarch64.dmg
.app はそのまま起動します。DMG は Finder にマウントされ、背景画像・アプリアイコン・Applications へのリンクが設定した位置に並んでいれば成功です。ユニバーサルビルドは lipo -archs <実行ファイル> で x86_64 arm64 と出れば正しく作れています。
よくあるエラーと対処法
別の Mac で「壊れているため開けません」と言われる
署名していない .app を Zip や DMG で配ると、ダウンロードした側で Gatekeeper に止められます。開発者本人が試すだけなら隔離属性を外せば起動します。
xattr -cr "/Applications/My Notes.app"
一般ユーザーに配布するなら Developer ID 証明書での署名と Apple の公証(notarization)が必要です。bundle.macOS.signingIdentity と環境変数 APPLE_ID などで設定し、tauri build に署名と公証を任せられます。
universal-apple-darwin でリンクに失敗する
error: failed to run custom build command や「target may not be installed」という趣旨のエラーは、片方のターゲットが rustup target add されていないのが原因です。前提条件のコマンドで両方を追加してください。
DMG のアイコン位置や背景が反映されない
DMG のレイアウトは Finder を AppleScript で操作して設定されるため、GUI セッションのない CI ランナーや、Finder の自動化許可を拒否した端末では既定の配置になります。ローカルで作った DMG を配布するか、CI ではレイアウトが崩れることを許容してください。
OS ごとの違いと注意点
- 既定のビルドはホストのアーキテクチャ(M1 以降なら
aarch64)のみです。Intel Mac ユーザーがいる場合は--target x86_64-apple-darwinか universal を用意します .appを Zip で配る場合は Finder の「圧縮」かditto -c -k --keepParentを使います。zip -rは拡張属性を壊すことがあります- identifier の末尾を
.appにしないでください。バンドル名と衝突して警告されます
