xcode iCloud 文档不可见

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26295176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:49:56  来源:igfitidea点击:

iCloud Documents not visible

iosobjective-cxcodeiclouduidocument

提问by Nostradamus

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.

我正在尝试使用 iCloud 文档来存储来自我的 iOS 应用程序的 XML 文件。一切似乎都运行良好(我可以无误地写入和读取文件),但我的应用程序文件既没有出现在 icloud.com 中,也没有出现在 developer.icloud.com 中,也没有出现在我的 Windows PC 中的 iCloud Drive 文件夹中。我在模拟器中运行该应用程序并在真实设备上使用 TestFlight 进行测试。我安装了最新版本的 iCloud for Windows 4.0。该应用程序是在 Xcode 6 中创建的。

Does anyone know how to make the files appear in iCloud Documents?

有谁知道如何使文件出现在 iCloud 文档中?

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

回答by Nostradamus

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

我发现了问题所在:iCloud 容器的 Info.plist 中的键与格式“iCloud.com.example.MyApp”有点不同。

回答by Totka

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

我按照此链接中的说明查看我的应用程序在 iCloudDrive 中创建的文件。我可以从“设置”>“iCloud”>“设备存储”中查看文件。希望能帮助到你。