【问题标题】:app runs in simulator, fails on iPad "missing required entitlement ... icloud-services"应用程序在模拟器中运行,在 iPad 上失败“缺少所需的权利 ... icloud-services”
【发布时间】: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 xcode ipad cloudkit


【解决方案1】:

此崩溃不是由于缺少任何权利,尽管异常表明它是。我不知道究竟是什么解决了这个问题,但我确实知道有效的过程,如下所示:

1) 创建一个相同类型的新 iOS 项目并确保它运行。

2) 在新应用中启用 CloudKit,并在 XCode 创建的默认控制器中添加#import "CloudKit/CloundKit.h"。

3) 添加语句“[CKContainer defaultContainer];”在 viewDidLoad() 方法中。

4) 再次运行应用程序并确保它不会因添加的语句而崩溃。

5) 检查旧应用中的所有应用属性,并确保所有值与新应用中的值相同。

最后一步包括十几个值更改,并解决了问题:旧应用不再在尝试访问 iCloud 时崩溃。

【讨论】:

    猜你喜欢
    • 2015-12-20
    • 2019-09-02
    • 1970-01-01
    • 2011-03-19
    • 2020-02-07
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多