【发布时间】:2017-09-25 14:48:45
【问题描述】:
我正在尝试将任意文件从我的应用程序沙箱保存到 iOS 10.3 模拟器上的 iCloud Drive。
iCloud Drive 已启用并且我已登录。如果我在模拟器上打开 iCloud Drive 应用程序,我会在其中看到文件。
所以,在我的应用中:
我通过以下方式获取容器:
[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]
这给了我这样的东西:
file:///Users/me/Library/Developer/CoreSimulator/Devices/F873A728-0314-4666-A137-830FF6280F05/data/Library/Mobile%20Documents/iCloud~com~me~iclouduploadtest/
然后我让我的沙盒文件无处不在,就像这样:
NSError *error;
if (![[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:url destinationURL:ubiquityURL error:&error])
{
NSLog(@"Error occurred: %@", error);
}
没有报告错误,如果我查看磁盘,我会看到文件从 url 消失并出现在 ubiquity 容器中(之前获得的路径)。
太棒了!所以我的文件在 iCloud 中!或不。
文件在 icloud.com 中不可见,在模拟器上的 iCloud Drive 应用中也不可见
在模拟器上运行的 NSMetadataQuery 在 iCloud 中找不到文件
即使在模拟器调试菜单中使用
Trigger iCloud sync之后我尝试
brctl log --wait --shorten并再次触发同步。没有错误报告。很多starting sync down,但没有关于同步up,适用于任何应用程序。
为什么我的文件没有上传到 iCloud?
我是不是做错了什么,还是错过了一步?
iCloud Drive 上传不能在 10.3 模拟器上工作吗?
【问题讨论】:
-
尝试按照这个答案stackoverflow.com/a/27358392/5031210 中描述的步骤进行操作,它在第一次设置 iCloud Drive 时帮助了我很多。 iCloud Drive 确实可以在模拟器上运行
标签: ios icloud icloud-drive