asc-notarization 是做什麼的?
使用 xcodebuild 和 asc 歸檔、匯出及公證 macOS 應用程式。當您需要準備以 Developer ID 簽署並經過 Apple 公證的 macOS 應用程式,以進行 App Store 以外的發佈時使用。
概述
此技能自動化了使用 xcodebuild 和 asc (Application Loader) 來建立、簽署和公證 macOS 應用程式的流程。它確保您的應用程式符合 Apple 的安全要求,可供分發。
必要條件
- 有效的 Apple Developer 帳戶
- 已安裝 Xcode 和命令列工具
- 已設定的 Developer ID 憑證
- 應用程式的 App Store Connect API 金鑰或應用程式專用密碼
使用方式
- 歸檔:使用
xcodebuild archive指令建立應用程式的歸檔。 - 匯出:使用
xcodebuild -exportArchive匯出歸檔,並指定 Developer ID 簽署。 - 公證:使用
xcrun altool --notarize-app或asc notarytool submit提交應用程式進行公證。 - 確認:檢查公證狀態,並在完成後為應用程式添加公證章。
範例指令
# 歸檔
xcodebuild archive -scheme MyApp -archivePath MyApp.xcarchive
# 匯出
xcodebuild -exportArchive -archivePath MyApp.xcarchive -exportPath MyApp-export -exportOptionsPlist exportOptions.plist
# 公證 (使用 notarytool)
xcrun notarytool submit MyApp-export/MyApp.pkg --apple-id "your-apple-id" --team-id "your-team-id" --password "app-specific-password" --wait
# 加章
xcrun stapler staple MyApp-export/MyApp.pkg
除錯
- 如果公證失敗,請檢查應用程式的權限和功能設定。
- 確認 Developer ID 憑證已正確安裝在鑰匙圈中。
- 確保匯出選項 plist 包含
distributionBundleIdentifier等必要資訊。