Mac app文件签名与公证

2,344 阅读1分钟

Mac app文件签名与公证

  1. 在钥匙串中创建要公证app的profile(公证的时候会用到)

    xcrun notarytool store-credentials "mac_app" --apple-id "xxxxxxxx@qq.com" --team-id "S24Z9326XX" --password "asgt-qjoe-tjep-xxxx"
    

    store-credentials:随便起名字,自己记住就行,后面会用

    apple-id:Apple ID

    team-id:团队ID developer.apple.com/account/ 可以查看到

    password:App专用密码,可以在AppleID管理那里生成

    image-20221110181136496

    image-20221110181309333

  2. 获取打包完成后的App文件,并cd到当前目录

    cd /Users/xxxx/Desktop/my_codes/Rust/cw-navigation/src-tauri/target/release/bundle/macos
    
  3. app签名

    codesign -f -o runtime -s "Developer ID Application: W L (S24Z9326XX)" -v cw-navigation.app --deep
    

image-20221110180131622

  1. app文件转为zip文件(不要右键压缩,会有mac文件系统隐藏文件)

    ditto -c -k --keepParent cw-navigation.app cw-navigation.app.zip
    

    image-20221110180336015

  2. 公证

    xcrun notarytool submit cw-navigation.app.zip --keychain-profile "mac_app" --wait
    

    image-20221110180456727

  3. 可以查看公证记录(报错时,可以查看具体报错信息)

    xcrun notarytool log "c5d0e8b4-f8ce-4104-90a2-78054bdb11c8" --keychain-profile "mac_app"
    # 公证时会返回有个id 通过这个id查询
    

参考资料

苹果(MacOS)桌面应用程序 签名及分发教程