2014-10-12 14 views
9

Meine iCloud Core Data-App lief auf iOS7 und war zum Starten bereit. Wenn ich auf iOS 8 teste, erhalte ich den folgenden Fehler und kann den Fehler nicht beheben, wenn ich versuche, Daten in iCloud hochzuladen.iCloud Core Data Der IOS8-Pfad befindet sich außerhalb eines beliebigen CloudDocs-Containers

Ich vermute, mein Problem ist damit zusammen, wie ich mit iOS8 das Dokumentenverzeichnis und Änderungen im Verzeichnis doc bin immer, aber ich kann das einfach nicht herausfinden ..

014-10-12 15:14:17.862 XXXXXXX [4662:236693] __45-[PFUbiquityFilePresenter processPendingURLs]_block_invoke(439): CoreData: Ubiquity: Librarian returned a serious error for starting downloads Error Domain=BRCloudDocsErrorDomain Code=6 "The operation couldn’t be completed. (BRCloudDocsErrorDomain error 6 - Path is outside of any CloudDocs container, will never sync)" UserInfo=0x7f8b1a525f60 {NSDescription=Path is outside of any CloudDocs container, will never sync, NSFilePath=/Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt} with userInfo { 
    NSDescription = "Path is outside of any CloudDocs container, will never sync"; 
    NSFilePath = "/Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt"; 
} for these urls: (
    "file:///Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt" 
) 

meine AppDelegate Dateisuffix wo Ich erstelle meinen persistenten Speicher wie folgt. Ich habe eine Seed-Datenbank für die Erstinstallation.

- (NSPersistentStoreCoordinator *)createPersistentStoreCoordinator{ 
    NSPersistentStoreCoordinator *persistentStoreCoordinator = nil; 
    NSManagedObjectModel *managedObjectModel = [self createManagedObjectModel]; 
    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]initWithManagedObjectModel:managedObjectModel]; 
    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@ 
    "CoreData.sqlite"];  

    if (![[NSFileManager defaultManager]fileExistsAtPath:[storeURL path]]){ 
     NSURL *preloadURL=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"SeedDatabase" ofType:@ 
     "sqlite"]]; 
     NSError *error=nil; 
     if (![[NSFileManager defaultManager] copyItemAtURL:preloadURL toURL:storeURL error:&error]){ 
      NSLog(@ 
      "File couldnt save"); 
     } 
    } 


    NSUbiquitousKeyValueStore *kvStore=[NSUbiquitousKeyValueStore defaultStore]; 
    if (![kvStore boolForKey:@"SEEDED_DATA"]){ 
     NSLog (@ 
     "In the new database"); 
     NSURL *seedStoreURL=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"SeedDatabase" ofType:@ 
     "sqlite"]]; 
     NSError *seedStoreErrpr; 
     NSDictionary *[email protected]{NSReadOnlyPersistentStoreOption: @YES}; 
     NSPersistentStore *seedStore=[persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:seedStoreURL options:seedStoreOptions error:&seedStoreErrpr]; 

     NSDictionary *iCloudOptions [email protected]{NSPersistentStoreUbiquitousContentNameKey: @"iCloud", 
             NSMigratePersistentStoresAutomaticallyOption:@YES, 
             NSInferMappingModelAutomaticallyOption:@YES 
     }; 

     NSOperationQueue *queue=[[NSOperationQueue alloc] init]; 
     [queue addOperationWithBlock:^{ 
      NSError *error; 
      [persistentStoreCoordinator migratePersistentStore:seedStore toURL:storeURL options:iCloudOptions withType:NSSQLiteStoreType error:&error]; 
      NSLog(@ 
      "Persistant store migrated"); 
      [kvStore setBool:YES forKey:@ 
      "SEEDED_DATA"]; 
      // [self checkForDuplicates]; 
     }]; 
    }else{ 
     NSError *error; 
     NSDictionary *storeOptions [email protected]{NSPersistentStoreUbiquitousContentNameKey: @ 
      "iCloud" 
     }; 
     if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType 
             configuration:nil 
             URL:storeURL 
             options:storeOptions 
             error:&error]) { 
      NSLog(@ 
      "Unresolved error %@, %@", error, [error userInfo]); 
      abort(); 
     } 
    } 

    return persistentStoreCoordinator; 
} 

- (NSURL *)applicationDocumentsDirectory{ 
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; 
} 
+1

Haben Sie eine Lösung gefunden? derselbe Fehler hier .. – MatterGoal

+1

Ich konnte dies lösen, indem ich das iCloud-Verzeichnis im icloudOptions-Wörterbuch spezifizierte. Ich musste es auch komplett von allen Geräten entfernen, die iCloud-Laufwerksdateien löschen und auf einem Gerät neu starten. Beitrag aktualisiert – grayentropy

+0

Ich bekomme den gleichen Fehler und frage mich, was tun Sie, wenn der Benutzer iCloud ausgeschaltet hat und der 'NSFileManager'' nil' zurückgibt, wenn Sie nach dem Cloud-Verzeichnis fragen? –

Antwort

5

Ich konnte diesen Fehler beheben, indem ich das iCloud-Laufwerksverzeichnis (denselben Namen wie auf der developer.apple.com-Schnittstelle) spezifizierte.

-(NSURL *)cloudDirectory 
{ 
NSFileManager *fileManager=[NSFileManager defaultManager]; 
NSString *[email protected]"iCloud"; 
NSString *bundleID=[[NSBundle mainBundle]bundleIdentifier]; 
NSString *cloudRoot=[NSString stringWithFormat:@"%@.%@",teamID,bundleID]; 
NSURL *cloudRootURL=[fileManager URLForUbiquityContainerIdentifier:cloudRoot]; 
NSLog (@"cloudRootURL=%@",cloudRootURL); 
return cloudRootURL; 
} 

und darunter in der icloudOptions Wörterbuch als NSPersistentStoreUbiquitousContentURLKey

NSDictionary *storeOptions [email protected]{NSPersistentStoreUbiquitousContentNameKey: @"iCloud", 
            NSPersistentStoreUbiquitousContentURLKey:[self cloudDirectory], 
            }; 

ich einige seltsame Fehler war immer so dass ich die App von allen Geräten entfernt, löschte die iCloud-Laufwerk Datei und wieder lief auf einem tatsächlichen Gerät und es hat gut funktioniert. Ich bin mir nicht sicher, ob es jetzt auf IOS7 läuft, aber da ich nur den NSPersistentStoreUbiquitousContentURLKey angegeben habe, bin ich mir ziemlich sicher, dass es in Ordnung sein sollte.

+1

Ich habe das versucht, aber ich bekomme: "Parsen von Komponenten von URL nicht fortsetzen:/var/mobile/Library/Mobile Dokumente/iCloud ~ com ~ Beispiel ~ foo/CoreData/MyAppCloudStore/.Baseline/MyAppCloudStore " – Ixx

+0

Was hast du bei der TeamID eingestellt? – user3065901

-1

Ich hatte das gleiche Problem beim Laden einiger Testdaten. Für das Laden der Daten löschte ich alle Datensätze. Um die Ausnahme zu vermeiden, war ein einfacher Schlaf (1) zwischen Säubern und Laden ausreichend.