ios - iCloud 同步失败并显示 "CoreData: Ubiquity: Invalid option: the value for NSPersistentStoreUbiquitousContentNameKey should not contain periods"

标签 ios core-data icloud magicalrecord

CoreData: Ubiquity: Invalid option: the value for NSPersistentStoreUbiquitousContentNameKey should not contain periods: com.YashwantChauhan.Outis

-PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:: CoreData: Ubiquity: mobile~20BF44C9-C39F-48DC-A8A1-B45FC82C7E20:com.YashwantChauhan.Outis

我在与 iCloud 同步时遇到问题。上面这两个错误是抛给我的。我不知道有什么问题,我设置了 Entitlements 文件,并将 Ubiquity Container 设置为 com.YashwantChauhan.Outis

我使用 MagicalRecord 的方法启动 CoreData 堆栈:

[MagicalRecord setupCoreDataStackWithiCloudContainer:@"N6TU2CB323.com.YashwantChauhan.Outis" localStoreNamed:@"Model.sqlite"];

但这根本不重要,因为 MagicalRecord 只是简化了 CoreData 方法。

非常感谢帮助。

确定更新:

-[NSFileManager URLForUbiquityContainerIdentifier:]: An error occurred while getting ubiquity container URL: Error Domain=LibrarianErrorDomain Code=11 "The operation couldn’t be completed. (LibrarianErrorDomain error 11 - The requested container identifier is not permitted by the client's com.apple.developer.ubiquity-container-identifiers entitlement.)" UserInfo=0x15e0d8a0 {NSDescription=The requested container identifier is not permitted by the client's com.apple.developer.ubiquity-container-identifiers entitlement.}

这是我收到的最新错误消息,我意识到这与问题的初始错误不同,但事实证明旧消息是某种奇怪的错误。我通过从我的 Ubiquity Container 标识符中删除句点来尝试@Rauru Ferro 的解决方案。我知道这是行不通的,因为标识符的要求是包含句点,但是当我把句点放回去时,它会吐出上面的错误消息。这比不使用句点更有意义。我们都知道我们 do .

我还发现了这个方便的代码片段,它实际上可以通过获取它来检查我的 Ubiquity Container 标识符。有用的片段可以快速检查您是否有任何问题。

NSString *containerId = @"com.YashwantChauhan.Outis";
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *iCloudURL = [fileManager URLForUbiquityContainerIdentifier:containerId];
NSLog(@"%@", [iCloudURL absoluteString]);

另一个更新:从外观上看,这个愚蠢的NSPersistentStoreUbiquitousContentNameKey should not contain periods一团糟。如果 NSPersistentStoreUbiquitousContentNameKey 被创建为某种文件夹 (Tutorial),则要求名称前面没有 .,例如 .com。 YashwantChauhan.Outis 但事实并非如此。我开始发疯了! Entitlements 文件没有问题,在 MagicalRecord 中获取 iCloud 容器 ID 也没有任何问题。我开始认为这是在 Xcode 5 中设置 iCloud 的内部问题,但我当然不知道。话虽如此,我可能只是因为一些琐碎的事情或实际上会让其他人头疼的事情而失去理智。

任何人都可以发布他们的权利文件,以便我可以验证实际工作版本的外观。当然是编辑过的。谢谢!

最佳答案

引用 https://forums.pragprog.com/forums/252/topics/12315

引用响应:

这最近发生了变化(小牛队)。幸运的是,由于您刚刚添加 iCloud,因此影响很小。

您需要更改以下代码行:

[options setValue:[[NSBundle mainBundle] bundleIdentifier] forKey:NSPersistentStoreUbiquitousContentNameKey]; 到别的地方。那是什么东西?我会推荐一些描述你的应用程序的东西。我最近一直在使用类似结构的类名。因此,我会将其更改为您的应用程序的名称,或者简称为“DataStorage”。

该名称对您的应用程序来说是唯一的,因此实际值并不重要,只要您能理解即可。

所以我更改了下面的代码...

        options = [NSDictionary dictionaryWithObjectsAndKeys:
                   [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,     // Key to automatically attempt to migrate versioned stores
               [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,           // Key to attempt to create the mapping model automatically
               @"TrafficCamNZ_DataStore", NSPersistentStoreUbiquitousContentNameKey,                // Option to specify that a persistent store has a given name in ubiquity.
               cloudURL, NSPersistentStoreUbiquitousContentURLKey,                              // Option to specify the log path to use for ubiquitous content logs.
               nil];

请参阅 TrafficCamNZ_DataStore 行 它以前有 TrafficCamNZ.DataStore

  • 大卫

关于ios - iCloud 同步失败并显示 "CoreData: Ubiquity: Invalid option: the value for NSPersistentStoreUbiquitousContentNameKey should not contain periods",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19209504/

相关文章:

ios - Objective-C prepareForSegue 问题

ios - 10 秒后超时功能 Swift/iOS

swift - MapKit 从核心数据添加多个注释

ios - 核心数据中与 self 的关系

iOS11 : Can't create folder again in iCloud drive once deleted manually

ios - 通过 NSDate 对象属性快速过滤

ios - 为什么我的 iAds 广告在 iPad 上损坏

ios - 将对象从多个存储保存到单个持久性存储

ios - 如何检查 iCloud 中是否有内容?核心数据

El Capitan 上锁定的 Git 存储库