我已经按照官方Apple文档从Xcode GUI对我的应用程序进行代码签名,这有效,即spctl -a -v
给了我:
$ spctl -a -v HelloCodeSign.app
HelloCodeSign.app: accepted
source=Developer ID
但是,当使用codesign命令行工具对同一应用程序的干净版本进行代码签名时,我收到以下错误:
$ codesign --force --sign "Developer ID Application: MyCompany, Inc." -vv HelloCodeSign.app
HelloCodeSign.app: replacing existing signature
HelloCodeSign.app: code failed to satisfy specified code requirement(s)
尝试了许多教程和StackOverflow帖子,但没有一个帮助。
是否有关于如何从命令行进行代码签名的分步说明?我不认为Apple对CLI版本的详细说明与其工作流程的GUI版本相同:
我尝试使用此技术说明:
https://developer.apple.com/library/mac/technotes/tn2206/_index.html
和“需求语法”部分似乎与上面的错误消息有关。但是,没有关于如何找出这些语法的值以使用特定应用程序的说明。所以它似乎毫无用处。
更新
我遵循了这个技术说明:
并使用此命令深入查看错误:
$ codesign --verify -vvvv -R='anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)' /path/to/HelloCodeSign.app
/path/to/HelloCodeSign.app: valid on disk
/path/to/HelloCodeSign.app: satisfies its Designated Requirement
test-requirement: code failed to satisfy specified code requirement(s)
关于错误消息,技术说明说:
This error indicates that the profile used to sign the app is missing its submission entitlement which can occur for example when a development Provisioning Profile is used to the sign the app instead of the intended distribution profile.
但是,我很确定我使用了正确的开发者ID来签署该应用。那里只有一个应用程序ID和一个安装程序ID,我使用前者。
更新2
我参考了技术说明并检查了应用程序的签名:
$ codesign -dvvv HelloCodeSign.app
Executable=HelloCodeSign.app/Contents/MacOS/HelloCodeSign
Identifier=com.mycompany.HelloCodeSign
Format=bundle with Mach-O thin (x86_64)
CodeDirectory v=20200 size=233 flags=0x0(none) hashes=4+3 location=embedded
Hash type=sha1 size=20
CDHash=8ca384ad68378c9bcde24dc4c1778d36a0048362
Signature size=4318
Authority=Mac Developer: My TeamAgent (WB764F5QV6)
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Signed Time=May 25, 2015, 5:00:53 PM
Info.plist entries=22
TeamIdentifier=BCB4VLKTK5
Sealed Resources version=2 rules=12 files=5
Internal requirements count=1 size=192
这些都是这些要求吗?我应该将它们添加到--requirments
开关吗?