LoginSignup
3
6

More than 1 year has passed since last update.

Command Line ToolのApple公証を行う

Last updated at Posted at 2020-02-06

Command Line ToolのApple公証を行う

  • XcodeでCommand line toolを作っている場合、.appと同じ様にOrganizerから公証を行うことができません。
  • Terminalからコマンドを叩く必要がありますが、必要な設定があり困りポイントが多かったので、そこ辺のTipsを共有します。

参考

実践

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

-w1064

署名設定

  • Auto Signingではなく、マニュアルで指定します。(Auto Signingだとうまく行かない?)
  • Developer ID Applicationを選択します。

-w846

hardened Runtimeを有効にする

-w636

ビルドの場所を変更する

-w838

ターミナルでビルド

  • 自分の場合クリーンがうまく行かなかったのでDerived Databuildを手動で削除した。
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対応をする

sudo codesign --force --options runtime --deep-verify --verbose --sign "Developer ID Application: xxx. (xxxxxxxxxx)" path/to/app
3
6
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
3
6