gpt4 book ai didi

ios - 我缺少什么才能让我的 iOS 应用程序获得 iCloud 授权?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:14:10 25 4
gpt4 key购买 nike

我正在尝试将 iCloud 功能添加到现有应用程序。我正在使用 UIManagedDocument 来引用核心数据。我对此进行了大量研究,但我无法弄清楚我做错了什么。

我试过让它在我的 Macbook 和 Mac Mini 上运行。我试过关闭 iCloud 功能,退出 Xcode,然后重新打开 Xcode 并重新打开 iCloud 功能。运气不好。

我觉得不合适的原因是:

  1. 我没有看到 Cloud Debug Gauge。
  2. 当我在模拟器中触发 iCloud 同步时,我收到一条错误消息:

The operation couldn’t be completed. (BRCloudDocsErrorDomain error 2 - Logged out - iCloud Drive is not configured)

  1. 以下解析为nil
    [[NSFileManager defaultManager] ubiquityIdentityToken]

设置截图

iCloud 功能已设置。

enter image description here

App ID 开启了 iCloud。

enter image description here

我的配置文件说它是为 iCloud 设置的。当我切换到我的 Mac Mini 时,我也撤销并重新授权。

enter image description here

我看到一篇关于 Xcode 6 beta 没有正确设置权利的帖子,但据我所知这是可以的。我确实尝试将 Ubiquity Container Identifier 更改为 $(TeamIdentifierPrefix)$(CFBundleIdentifier) 但它似乎没有什么不同。

enter image description here

代码

也许问题出在我的代码上?下面唯一的新部分是 NSPersistentStoreUbiquitousContentNameKey: @"iCloudStore"

NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask] firstObject];
url = [url URLByAppendingPathComponent:DATABASE_DOCUMENT_NAME];
self.document = [[UIManagedDocument alloc] initWithFileURL:url];

// To cause light-weight model version migration to occur.
self.document.persistentStoreOptions = @{
NSMigratePersistentStoresAutomaticallyOption : @YES,
NSInferMappingModelAutomaticallyOption : @YES,
NSPersistentStoreUbiquitousContentNameKey: @"iCloudStore"
};

在上面的代码之后,它会执行 openWithCompletionHandlersaveToURL:url forSaveOperation:UIDocumentSaveForCreating。我还注册了有关 NSPersistentStoreCoordinatorStoresDidChangeNotification 的通知,这正在发生。

最佳答案

iCloud Debug Gauge 可能不适用于在模拟器中运行的应用程序,因为它没有完整的功能。这是 2014 年的数据,所以情况可能有所改变。

However, iCloud Core Data is not fully supported in the simulator. When testing across devices and the simulator, it seems that iCloud Core Data on the simulator only uploads changes, and never pulls them back down. This is still a big improvement over needing separate test devices, and a nice convenience, but iCloud Core Data support on the iOS Simulator is definitely not fully baked yet.

http://www.objc.io/issues/10-syncing-data/icloud-core-data/

我在官方文档中唯一能找到的是:

It is especially important to test an iCloud-enabled iOS app on an actual device. iOS Simulator doesn’t accurately simulate the use of iCloud under real-world conditions.

https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/UsingCoreDataWithiCloudPG/UsingSQLiteStoragewithiCloud/UsingSQLiteStoragewithiCloud.html

关于ios - 我缺少什么才能让我的 iOS 应用程序获得 iCloud 授权?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32162912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com