Xocde 5 and iCloud


Using iCloud in Xcode 5 was super easy… just turn on and a few clicks. :laughing:

Keeping coredata in the sandbox runs fine.

Moving coredata into the ubiquity container causes this warning: [quote]+PFUbiquityLocation createUbiquityLocationForPath:withUbiquityRootLocation:: CoreData: Ubiquity: It appears the store file is nested inside the container log directory. This is a really bad idea:[/quote]

BNRFeedStore.m > init

[code]- (id)init
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self

    model = [NSManagedObjectModel mergedModelFromBundles:nil];
    NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
    // find the location of the ubiquity container on the local filesystem
    NSFileManager *fm  = [NSFileManager defaultManager];
    NSURL *ubContainer = [fm URLForUbiquityContainerIdentifier:nil];
    // construct the dictionary that tells core data where the transaction log should be stored
    NSMutableDictionary *options = [NSMutableDictionary dictionary];
    [options setObject:@"nerdfeed" forKey:NSPersistentStoreUbiquitousContentNameKey];
    [options setObject:ubContainer forKey:NSPersistentStoreUbiquitousContentURLKey];
    NSError *error = nil;
    //NSString *dbPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    //dbPath = [dbPath stringByAppendingPathComponent:@"feed.db"];
    //NSURL *dbURL = [NSURL fileURLWithPath:dbPath];
    // specify a new directory and create it in the ubiquity container
    NSURL *nosyncDir = [ubContainer URLByAppendingPathComponent:@"feed.nosync"];
    [fm createDirectoryAtURL:nosyncDir withIntermediateDirectories:YES attributes:nil error:nil];
    // specify new file to store core data's sqlite file
    NSURL *dbURL = [nosyncDir URLByAppendingPathComponent:@"feed.db"];
    // added options dictionary
    if (![psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:dbURL options:options error:&error]) {
        [NSException raise:@"Open failed" format:@"Reason: %@", [error localizedDescription]];
    context = [[NSManagedObjectContext alloc] init];
    [context setPersistentStoreCoordinator:psc];
    [context setUndoManager:nil];
return self;

But apple docs states: [quote]When you use a SQLite Core Data store with iCloud, keep the following points in mind:

Place your SQLite Core Data store within a <my_folder>.nosync subdirectory of one of your app’s ubiquity containers. This placement ensures that, if a user switches iCloud accounts, the system takes care of keeping each account’s data associated with the correct account.[/quote]

Anybody know how to prevent this warning? The app still works fine but continues to generate the warning over and over and over and…


I’m having the exact same problem. Have you found a solution? I have a core data store that I’m trying to migrate to icloud using migratePersistentStore and I have the nosync directory set up just like you do. It’s throwing the same “It appears the store file is nested inside the container log directory”. But my problem is that my data store isn’t actually migrating (the new store sqlite file never appears) and it’s not throwing any error. Very frustrating… I thought this stuff was supposed to be fixed for ios7???

I’m just curious - do you have the “allow external storage” option checked for any of your binary data attributes? I’m wondering if that’s related to what caused it. In ios6 this caused trouble migrating the stores by throwing an error saying core data couldn’t parse the directory (I decided to just release the first version without iCloud because all of the core data and icloud stuff was so flakey).