Ios iCloud文档不可见
我正在尝试使用iCloud文档存储iOS应用程序中的XML文件。除了我的应用程序文件没有显示在iCloud文档中,无论是在iCloud.com、developer.iCloud.com还是在我的Windows PC的iCloud Drive文件夹中之外,一切似乎都很正常(我可以无错误地写入和读取文件)。我在模拟器中运行应用程序,并在真实设备上用TestFlight进行测试。我安装了最新版本的iCloud for Windows 4.0。该应用程序是在Xcode 6中创建的 有人知道如何使文件出现在iCloud文档中吗 我用于保存文件的代码:Ios iCloud文档不可见,ios,objective-c,xcode,icloud,uidocument,Ios,Objective C,Xcode,Icloud,Uidocument,我正在尝试使用iCloud文档存储iOS应用程序中的XML文件。除了我的应用程序文件没有显示在iCloud文档中,无论是在iCloud.com、developer.iCloud.com还是在我的Windows PC的iCloud Drive文件夹中之外,一切似乎都很正常(我可以无错误地写入和读取文件)。我在模拟器中运行应用程序,并在真实设备上用TestFlight进行测试。我安装了最新版本的iCloud for Windows 4.0。该应用程序是在Xcode 6中创建的 有人知道如何使文件出现
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");
}
我按照此处的说明在iCloudDrive中查看我的应用程序创建的文件。我可以从设备的“设置”>“iCloud”>“存储”中查看文件。希望有帮助。我发现了问题所在:
iCloud容器的Info.plist中的键与格式“iCloud.com.example.MyApp”有点不同。FWIW,我不想费心创建容器目录,它工作正常。请确保为使Info.plist更改生效而修改版本和内部版本号。@SteveMoser对此非常感谢,它解决了我的问题——我担心这与iCloud有关,或者我的代码没有考虑某些用例,但它真的很简单。@SteveMoser把你的版本作为答案有意义吗?这对我来说很有效,但我上次在这个问题上错过了!