【发布时间】:2016-08-10 19:05:55
【问题描述】:
将 iCloud 添加到工作中的 iOS 应用程序中,数据存储在公共数据库中。我必须在模拟器中登录 iCloud,但完成后,应用程序在模拟器中运行良好。在 iPad 上,程序在以下语句中崩溃:
CKContainer * dbContainer = [CKContainer defaultContainer];
应用程序被终止“由于未捕获的异常'CKException',原因:'应用程序缺少所需的权利 com.apple.developer.icloud-services'
当我在 XCode 中打开 iCloud 功能时,XCode 在 com.apple.developer.icloud-services 的 .entitlements 文件中创建一个条目,数组中有一项:值为“CloudKit”的字符串。
在我的 iPad 上,我以与在模拟器上相同的方式登录 iCloud。
我已经多次详细阅读了 Apple 的权利故障排除指南,我已经搜索了所有我知道的方法,但我无法弄清楚为什么会失败。我确实找到并阅读了建议为重复的帖子,但建议的解决方案都不适合我。
发布此问题后,我再次浏览了权利故障排除指南,并在构建的应用程序中找到了以下权利部分:
<dict>
<key>keychain-access-groups</key>
<array>
<string>PTXZTRRTHH.*</string>
</array>
<key>get-task-allow</key>
<true/>
<key>application-identifier</key>
<string>PTXZTRRTHH.com.quipzl.Quipzl</string>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>PTXZTRRTHH.*</string>
<key>com.apple.developer.icloud-services</key>
<string>*</string>
<key>com.apple.developer.icloud-container-environment</key>
<array>
<string>Development</string>
<string>Production</string>
</array>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.com.quipzl.Quipzl</string>
</array>
<key>com.apple.developer.icloud-container-development-container-identifiers</key>
<array>
<string>iCloud.com.quipzl.Quipzl</string>
</array>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>iCloud.com.quipzl.Quipzl</string>
</array>
<key>com.apple.developer.team-identifier</key>
<string>PTXZTRRTHH</string>
<key>aps-environment</key>
<string>development</string>
</dict>
该应用程序确实在我的 iPad 上运行 - 直到执行到上面的代码,当它引发异常时。为什么?
【问题讨论】:
-
不是重复的——我的应用还没有进入应用商店,而且在 iOS 9 中每次都失败,而不仅仅是第一次。打开和关闭 iCloud 并不能解决问题。