Command Line ToolのApple公証を行う
- XcodeでCommand line toolを作っている場合、
.app
と同じ用にOrganizer
から公証を行うことができません。 Terminal
からコマンドを叩く必要がありますが、必要な設定があり困りポイントが多かったので、そこ辺のTipsを共有します。
参考
- Notarize a Command Line Tool
- 大筋この通りで問題ないと思います。
- Resolving Common Notarization Issues
- 細かい設定の仕方もリファレンスをよく見れば載っていました。
- manpagez: man pages & more man codesign(1)
- codesign(1) についてのメモ
- macOSアプリに埋め込む実行バイナリのNotarization/Hardened Runtime対応は署名すればOK
実践
- 基本以下の通り行います。
Xcodeプロジェクトの設定
- 下2つが記事に載って無くて苦労したポイントなので共有します。
Time Stamp
Terminal
からビルドする際はTime Stampが含まれないので、設定を行います。- Resolving Common Notarization Issues
- > In this case, be sure to add a secure timestamp by adding the --timestamp flag to your OTHER_CODE_SIGN_FLAGS build setting
Avoid the Get-Task-Allow Entitlement
- デバッグを行うためにセキュリティを緩めるフラグがデフォルトで立っています。
Terminal
からビルドする場合はこのフラグが削除されないので、予め設定からフラグを落としておく必要があります- Resolving Common Notarization Issues
- > set the CODE_SIGN_INJECT_BASE_ENTITLEMENTS build setting to NO before building your app for distribution
署名設定
- Auto Signingではなく、マニュアルで指定します。(Auto Signingだとうまく行かない?)
Developer ID Application
を選択します。
hardened Runtimeを有効にする
ビルドの場所を変更する
ターミナルでビルド
- 自分の場合クリーンがうまく行かなかったので
Derived Data
やbuild
を手動で削除した。
xcodebuild clean install
- pkg作成
pkgbuild --root build/pkgroot \--identifier"com.example.hello"\--version"1.0"\--install-location"/"\--sign"Developer ID Application: xxx. (xxxxxxxxxx)"\
build/hello-1.0.pkg
- Appleの公証
xcrun altool --notarize-app\--primary-bundle-id"com.example.com"\--username"xxx@xxx.co.jp"\--password"@keychain:AC_PASSWORD"\--file"build/hello-1.0.pkg"
- 公証の状況確認(エラーが出たらここからログを確認できます)
xcrun altool --notarization-info"xxx-xxx-xxx-xxx-xxx"-u"xxx@xxx.co.jp"-p"@keychain:AC_PASSWORD"
再署名する際にHardened Runtime対応をする
- (今回は関係ないですが…)
- 再署名する際に通常だと、ビルド時に設定した
Hardened Runtime
がオフになるので、オプションで指定する必要があります - macOSアプリに埋め込む実行バイナリのNotarization/Hardened Runtime対応は署名すればOK
- > codesign コマンドに
--options runtime
をつけてバイナリを署名することで、Hardened Runtime対応となります。
- > codesign コマンドに
sudo codesign --force--options runtime --deep-verify--verbose--sign"Developer ID Application: xxx. (xxxxxxxxxx)"