Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iCloud sync fails with "CoreData: Ubiquity: Invalid option: the value for NSPersistentStoreUbiquitousContentNameKey should not contain periods"

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

I have a problem with syncing with iCloud. These two errors above are thrown at me. I don't know what's the problem, I setup the Entitlements file, and set the Ubiquity Container to com.YashwantChauhan.Outis.

I start the CoreData stack using MagicalRecord's method:

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

But that shouldn't even matter since MagicalRecord just simplifies CoreData methods.

Help much appreciated.

Ok update:

-[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.}

This is the latest error message I got, I realize this differs from the question's initial error but it so turns out that the old message was some kind of strange bug of sorts. I tried @Rauru Ferro's solution by removing the periods from my Ubiquity Container identifier. I knew that this wouldn't work because the requirements for the identifier is to contain periods, but then when I put the periods back in, it spat the error message above. Which makes more a lot more sense than not using periods. We all know that we do.

I also found this handy code snippet that can actually checks my Ubiquity Container identifier by fetching it. Useful snippet to quickly check if you have any problems with it.

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

Another update: By the looks of it, this stupid NSPersistentStoreUbiquitousContentNameKey should not contain periods is a whole mess. If NSPersistentStoreUbiquitousContentNameKey is created like some kind of folder (Tutorial), then the requirement is that there is no . infront of the name, like .com.YashwantChauhan.Outis but that is not the case. I am starting to go mad here! There is no problem with the Entitlements file and there is nothing with fetching the iCloud container ID in MagicalRecord. I am starting to think this is an internal problem with setting up iCloud in Xcode 5, but of course I don't know. With this said, I might just be loosing my mind over something trivial or something that will actually cause a headache for other people.

Can anybody post their Entitlements file so I can verify how an actual working version looks like. Redacted of course. Thank you!

like image 333
Souljacker Avatar asked Oct 06 '13 13:10

Souljacker


2 Answers

refer https://forums.pragprog.com/forums/252/topics/12315

Quoting the response:

This was changed recently (Mavericks). Fortunately for you, since you are just now adding iCloud, the impact is minimal.

You need to change the following line of code:

[options setValue:[[NSBundle mainBundle] bundleIdentifier] forKey:NSPersistentStoreUbiquitousContentNameKey]; To something else. What is that something else? I would recommend something descriptive to your application. I have been using class name like structures recently. So I would change it to be the name of your app perhaps or simply “DataStorage”.

The name is unique to your application so the actual value is not important as long as it is understood by you.

So I changed my code below...

        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];

Refer the line that says TrafficCamNZ_DataStore it previously had TrafficCamNZ.DataStore

  • David
like image 200
David Wilson Avatar answered Nov 02 '22 22:11

David Wilson


I am using a shared container and just had the same error warning popping up. I could fix it by replacing all occurrences of varying cloud identifier strings like:

  • "$(TeamIdentifierPrefix)com.mydomain.myapp" and
  • "com.mydomain.myapp" and
  • "ABCDEF0123.com.mydomain.myapp"

with just this one explicit cloud container string:

  • "ABCDEF0123.com.mydomain.myapp"

I guess that at some point, Xcode must have updated the entitlements and re-inserted the "$(TeamIdentifierPrefix)", which was wrong due to the shared container. Also, I had forgotten the identifer in code, just like you seemed to have:

NSString *containerId = @"com.YashwantChauhan.Outis";

that should probably be something like:

NSString *containerId = @"ABCDEF01234.com.YashwantChauhan.Outis";
like image 45
auco Avatar answered Nov 02 '22 23:11

auco