如何在 iOS 应用程序之间共享钥匙串数据
我正在描述一个问题,我花了相当长的时间才找到答案。
“GenericKeychain" 示例在 init 中使用 accessGroup 时,提供一个用于在应用程序之间共享钥匙串数据的包装器是一个良好的开端。
然而,在我的应用程序中实现此操作产生了一个模糊的错误代码(花了很长时间才找到)-25243,这意味着:没有访问控制。
我在 iPad 上运行 Apple 的示例应用程序 (GenericKeychain),却出现了同样的错误。啊?
Apple 的文档是否未能提供实现此目标所需的内容?
I am describing a problem for which it took me quite some time to learn the answer.
The "GenericKeychain" example is a good start at providing a wrapper for sharing keychain data between applications when using the accessGroup in the init.
However, implementing this in my app yielded an obscure error code (which took forever to locate) -25243, which means: No access control.
I ran Apple's example app (GenericKeychain) on my iPad only to get the same error. Huh?
Does Apple's documentation fail to deliver on what is necessary to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过一些(大量)网络挖掘后,我找到了答案。构建 KeychainItemWrapper 类时使用的访问组还必须在每个应用程序的 Entitlements.plist 文件的“keychain-access-groups”部分中指定。
现在我看到“钥匙串访问组”似乎几乎是显而易见的。然而,我根本不知道要去那里看看。希望这对其他人有帮助。
After some (a lot of) digging throughout the web, I found the answer. The access Group that you use when constructing your KeychainItemWrapper class must ALSO be specified in each of your application's Entitlements.plist file in the "keychain-access-groups" section.
It seems almost obvious now that I see "keychain-access-groups". However, I had no idea to even look there. Hope this helps others.
其实这并不难做到。请按照步骤操作。
App1:
并将这些代码添加到您需要的地方。
App2:
并将这些代码添加到您需要的位置。
两个项目的 TeamID 应相同。
Actually it's not hard to do. Please follow the steps.
App1:
And add these codes to somewhere you need.
App2:
And add these codes to somewhere you need.
Your TeamIDs should be same for both projects.