iCloud Documents not visible

戏子无情 提交于 2019-11-30 13:18:45

问题


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");
    }

回答1:


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".




回答2:


I follow instructions at this link to see files created by my app in iCloudDrive. I can see file from settings>iCloud>Storage from device. Hope it helps.



来源:https://stackoverflow.com/questions/26295176/icloud-documents-not-visible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!