macOS公证

611 阅读2分钟

什么是公证?

官网资料:wiki.lazarus.freepascal.org/Notarizatio…

这里简单说下公证是个啥?

由于MacApp的分发渠道只有两种:

  • 1、App Store
  • 2、各大软件网站

App Store 安装的 App 因为经过苹果审核,安全性是有保证的。而如果是从网站上下载,安全性则会打一个折扣。公证就是为了解决这个问题。

公证指的是开发者将没有经过 App Store 的 App 递交给苹果完成扫描,确保 App 没有任何可能危害到用户的恶意内容。这里要注意,公证不同于苹果审核,是一个完全自动化检验过程,结果返回非常快。

怎么拿已经开发好的App去做公证?

方式一

  • 使用Xcode
  • Product - Archive - Distribute App - Developer ID - Upload

image.png

image.png

image.png

这里一定要选择UploadXcode才会帮你去自动做公证,如果选择Export的话就需要自己去手动做公证了

然后点击下一步,选择应用的描述文件,之后点击上传Xcode就会帮你自动的上传你的App到Apple服务器中,大概等个10-20分钟吧,就会有结果了。

点击Window - Organizer

image.png

点击导出App即可,分发App了,此时的App是.app文件,你可以打包成dmg文件分发到官网上去。

方式二

  • 使用 xcrun notarytool 命令行工具

  • 先获取描述文件

➜ xcrun altool --list-providers -u "xxx@qq.com"

然后会提示你输入密码,这个密码不是你的AppID的密码,而是登录appleid.apple.com这个网址去生成一个秘钥的密码。比如fvvw-lcye-oibs-wvjgs

然后秘钥验证成功后,会在终端输入你所在的开发者的组织信息。

  • 存储证书
xcrun notarytool store-credentials --apple-id "xxx@qq.com" --password "fvvw-lcye-oibs-wvjgs" --team-id "CPL4GGGSS"

然后输入描述文件的名称,后续会用到,比如这里我们输入的名称是NotaryProfile

成功后会在终端输出以下结果:

This process stores your credentials securely in the Keychain. You reference these credentials later using a profile name.

Profile name:
UUSafeNotaryProfile
Validating your credentials...
Success. Credentials validated.
Credentials saved to Keychain.
To use them, specify `--keychain-profile "NotaryProfile"`
  • 使用命令行公证
zippath="path/xx.app.zip"
➜ xcrun notarytool submit $zippath --keychain-profile "NotaryProfile" --wait