I am trying to use iCloud Documents to store XML files from my iOS App. Everything seems to be working fine (I can write and read files without errors) except my App's files do not show up in iCloud Documents neither in icloud.com nor in developer.icloud.com nor on my Windows PC in iCloud Drive folder. I was running the app in simulator and tested with TestFlight on a real device. I have the latest version of iCloud for Windows 4.0 installed. The App is created in Xcode 6.
Does anyone know how to make the files appear in iCloud Documents?
The code I am using for the saving the file:
NSLog(@"Syncing with iCloud");
NSURL *ubiq = [filemgr URLForUbiquityContainerIdentifier:nil];
if (ubiq) {
NSURL *ubiquitousPackage = [ubiq URLByAppendingPathComponent:@"Documents" isDirectory:YES];
if ([filemgr fileExistsAtPath:[ubiquitousPackage path]] == NO)
[filemgr createDirectoryAtURL:ubiquitousPackage
withIntermediateDirectories:YES
attributes:nil
error:nil];
ubiquitousPackage = [ubiquitousPackage URLByAppendingPathComponent:@"data.pxa"];
DataFile *file = [[DataFile alloc] initWithFileURL:ubiquitousPackage];
file.xmlContent = doc.XMLString;
[file saveToURL:[file fileURL] forSaveOperation:UIDocumentSaveForCreating | UIDocumentSaveForOverwriting completionHandler:^(BOOL success) {
if (success) {
NSLog(@"Synced with iCloud: %@", [ubiquitousPackage path]);
} else {
NSLog(@"Syncing with iCloud failed");
}
}];
} else {
NSLog(@"iCloud not available");
}
I found out what the problem was: The key in Info.plist for the iCloud container was a bit different from the format "iCloud.com.example.MyApp".