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

4

9

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!

Engelbert answered 6/10, 2013 at 13:40 Comment(5)
Same issue here, exactly as described above. My entitlements string: $(TeamIdentifierPrefix)nl.amstaxi.taxiritPinkerton
Hmm... In addition to this, I changed the dots in ~ (this is what your code snippet also did when logging [iCloudURL absoluteString]). so for example: N6TU2CB323~com~YashwantChauhan~Outis When the app starts, it starts on local storage, but after about half a minute it switches to iCloud and my data starts to synchronize. See the logs in my next comments:Pinkerton
2013-10-23 15:13:06.471 taxirit[8721:1403] [PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity: antonbremer~sim3C257916-104C-56A7-826D-B7751C4E2E29:CPM35UK853~nl~amstaxi~taxirit Using local storage: 1Pinkerton
2013-10-23 15:13:40.099 taxirit[8721:3d03] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity: antonbremer~sim3C257916-104C-56A7-826D-B7751C4E2E29:CPM35UK853~nl~amstaxi~taxirit Using local storage: 0Pinkerton
@Pinkerton ,you are right!! I love you!!!Flosi
U
5

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
Urrutia answered 3/2, 2014 at 10:1 Comment(1)
TrafficCamNZ_DataStore may not have '_' neither '.', no matter what the error says. So make a simple string (like TrafficCamNZDataStore) or it will be mad to change it... I'm trying to migrate a document from one url to another and it is insaneDm
E
2

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";
Etching answered 19/6, 2015 at 15:0 Comment(1)
¿Do you know the way to migrate a uimanageddocument without losing all the data? We have an old app which was working with a dotted NSPersistentStoreUbiquitousContentNameKey and now in iOS9 is not working any more. If you could help i would be apprecieated ;). ThanksDm
P
1

I had the same issue and I am not sure what the issue is or why it is there. From what I am reading we should be able to use the dots in the containerId.

However, for me it started working by replacing the dots in the containerId with tildes:

i.e.:

NSString *containerId = @"N6TU2CB323~com~YashwantChauhan~Outis";

instead of:

NSString *containerId = @"N6TU2CB323.com.YashwantChauhan.Outis";
Pinkerton answered 23/10, 2013 at 14:6 Comment(0)
M
0

Try to use comYashwantChauhanOutis, without the two points.

Maros answered 6/10, 2013 at 19:4 Comment(5)
Check my update, this solution didn't solve the issue, but fortunately spat an error message that actually makes sense.Engelbert
I don't know if it could be useful by I've found this link: blarg.bworby.com/?p=448Maros
Good link @Raura Ferro. I just realized when you edit the iCloud field for the Ubiquity Container Identifier in Xcode 5.0, it will automatically add $(TeamIdentifierPrefix) to the identifier in the Entitlements file. Also that I am now back at my old error message. The one with the periods.Engelbert
The code snippet from the link that generates testCloudURL is valid though.Engelbert
Has anyone found a real answer to this one yet?Inulin

© 2022 - 2024 — McMap. All rights reserved.