简体   繁体   English

通过插件和iTunesLibrary共同设计OS X应用

[英]Codesigning OS X app with plugins and iTunesLibrary

I have a really weird codesigning problem. 我有一个很奇怪的代码签名问题。 A previous, almost identical version has passed validation and been submitted to the App Store, so my codesignature isn't broken. 以前几乎相同的版本已通过验证,并已提交到App Store,因此我的代码签名没有损坏。

Recently I've been trying to use the iTunesLibrary framework. 最近,我一直在尝试使用iTunesLibrary框架。 This framework only works if your application is codesigned. 仅当您的应用程序经过代码签名时,此框架才有效。 I'm getting a common error when trying to initialize the framework that indicates a codesigning failure: 尝试初始化指示代码签名失败的框架时,出现一个常见错误:

Error Domain=NSPOSIXErrorDomain Code=100001 "Could not load." 错误域= NSPOSIXErrorDomain代码= 100001“无法加载。” UserInfo=0x100329d80 {NSLocalizedDescription=Could not load., NSUnderlyingError=0x10031a430 "The operation couldn't be completed. (OSStatus error 100005.)"} UserInfo = 0x100329d80 {NSLocalizedDescription =无法加载。,NSUnderlyingError = 0x10031a430“操作无法完成。(OSStatus错误100005。)”}

My app is organized into multiple frameworks both dynamically linked and plugins. 我的应用程序分为动态链接和插件的多个框架。 I have been using the --deep flag to recursively sign my application, but apparently this is wrong . 我一直在使用--deep标志来递归地签名我的应用程序,但是显然这是错误的 Now I'm using a run script build phase to sign each of my frameworks and plugins. 现在,我正在使用run script构建阶段来对我的每个框架和插件进行签名。 This seems to work as codesign tells me the app is signed. 这似乎可以正常工作,因为codesign告诉我该应用程序已签名。

I've built the app in debug mode as well as archived it and exported as a Developer ID signed program and checked the signature -- both build modes pass. 我已经在调试模式下构建了该应用程序,并将其存档并导出为开发人员ID签名的程序并检查了签名-两种构建模式都可以通过。 When I run it, I get the above error from iTunesLibrary . 当我运行它时,我从iTunesLibrary收到以上错误。 The really weird part is, if I export the app and re-sign it myself as below, then iTunesLibrary functions properly: 真正奇怪的部分是,如果我导出应用程序并按如下所示重新签名,则iTunesLibrary可以正常运行:

codesign --force --sign "MyIdentity" --deep MyApp.app

If I use spctl --assess to try to tell me more about this, I learn that this application despite working properly is badly signed: 如果我使用spctl --assess试图告诉我更多有关此方面的信息,那么我将了解尽管该应用程序工作正常,但签名错误:

/Users/me/Desktop/MyApp.app: rejected

The app that iTunesLibrary doesn't like on the other hand passes spctl inspection: 另一方面, iTunesLibrary不喜欢的应用通过了spctl检查:

/Users/me/Desktop/MyApp.app: accepted
source=Developer ID
origin=Developer ID Application: Me

The solution is to link the iTunesLibrary framework to your main executable as well as to the framework that is actually using it. 解决方案是将iTunesLibrary框架链接到您的主要可执行文件以及实际使用它的框架。

I'd love to know why... 我想知道为什么...

If you're embedding frameworks, you will need to create a “Copy Files” Build Phase that moves your.framework into the Frameworks destination. 如果要嵌入框架,则需要创建一个“复制文件”构建阶段,以将您的框架移到“框架”目标中。 After your added Build Phase, add a run script with something such as: 在添加构建阶段之后,添加带有以下内容的运行脚本:

LOCATION="${BUILT_PRODUCTS_DIR}"/"${FRAMEWORKS_FOLDER_PATH}"
IDENTITY="Developer ID Application: Certificate Common Name"
codesign --verbose --force --sign "$IDENTITY" "$LOCATION/your.framework/Versions/A"

In short the --deep flag can't do the job properly. 简而言之,-- --deep标志不能正确完成这项工作。 Yes, it recursively signs the nested bundles, however, it applies the parameters for the top-level bundle to all the nested bundles. 是的,它递归地对嵌套包进行签名,但是,它将顶级包的参数应用于所有嵌套包。 In turn your app's entitlements will cause the resulting bundles to be invalid. 反过来,您的应用程序的权利将导致产生的捆绑软件无效。

man codesign --deep also states: man codesign --deep还指出:

; ; anything nested indirectly will require recursive application of the codesign command. 间接嵌套的任何内容都需要递归应用codesign命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM