[英]Can I add a file to iCloud via my Mac and use the file within an iOS application
I'm using Xcode 6.3.2 to develop an application for iOS 8.3 which needs to pull CSV files from a user's iCloud account. 我正在使用Xcode 6.3.2为iOS 8.3开发一个应用程序,它需要从用户的iCloud帐户中提取CSV文件。 These spreadsheets will be generated by a separate system and saved into the user's iCloud Drive folder (there will be multiple spreadsheets, in the app the user will type in a key string which determines which spreadsheet should be accessed), the method for doing so will be handled my client and unless it can't be done a special way, isn't relevant.
这些电子表格将由一个单独的系统生成并保存到用户的iCloud Drive文件夹中(将有多个电子表格,用户将在应用程序中键入一个确定应访问哪个电子表格的密钥字符串),这样做的方法将处理我的客户,除非不能以特殊方式完成,否则无关紧要。 The application itself needs to take a key string and search the user's iCloud drive for that file, if it exists get the contents of the file and if possible, save it locally so it can be accessed even if the iCloud Drive is unavailable.
应用程序本身需要获取一个密钥字符串并在用户的iCloud驱动器中搜索该文件,如果存在则获取该文件的内容,如果可能,将其保存在本地,以便即使iCloud Drive不可用也可以访问它。
The current application works with local CSV files within the application bundle (ones I've copied into my Xcode project), so now I need to integrate the iCloud functionality. 当前应用程序使用应用程序包中的本地CSV文件(我已复制到我的Xcode项目中),因此现在我需要集成iCloud功能。
Solved:
I've read various tutorials which show you how to upload and download to/from the iCloud Drive, although I'm still a bit confused as to how it works.
解决:
我已经阅读了各种教程,向您展示如何上传和下载到iCloud Drive,或者从iCloud Drive下载,尽管我仍然对它的工作方式感到困惑。
Which leads me to question one.
这让我质疑一个问题。
I'm currently assuming the latter of question one is correct, however I'm now worried I've misunderstood how it works (hence question one).
我现在假设后一个问题是正确的,但我现在担心我误解了它是如何工作的(因此问题一)。
I've setup the application to use iCloud - it successfully grabs the ubiquity URL but when querying for any CSV files it returns nothing.
我已经设置了使用iCloud的应用程序 - 它成功地抓住了无处不在的URL,但在查询任何CSV文件时它什么也没有返回。
I'm currently using the simulator and have read that it should work, although other sources suggest it wont, on the simulator I've logged in with the appropriate Apple ID and enabled iCloud Drive - however the files I placed in my iCloud Drive folder on my iMac aren't visible.
我目前正在使用模拟器并已阅读它应该可以工作,虽然其他消息来源建议它不会,在模拟器上我已使用相应的Apple ID登录并启用了iCloud Drive - 但是我放在iCloud Drive文件夹中的文件在我的iMac上看不到。
Onto question 2...
问题2 ......
EDIT: I've done some further digging and managed to get iCloud working on an actual device - which I guess answers question 2: iCloud Document Storage doesn't work properly on the iOS Simulator. 编辑:我已经做了一些进一步的挖掘,并设法让iCloud在一个实际的设备上工作 - 我想回答问题2:iCloud文档存储在iOS模拟器上无法正常工作。 I've also seen tutorials or screenshots showing that my assumptions of question 1 were correct.
我也看过教程或截图,显示我对问题1的假设是正确的。
Now I'm at the point when I can see my app has documents stored in iCloud when going to Settings > iCloud > Storage > Manage Storage on my iPad, and when I go to System Preferences > iCloud > Manage. 现在,当我进入设置> iCloud>存储>管理iPad上的存储,以及进入系统偏好设置> iCloud>管理时,我可以看到我的应用程序在iCloud中存储了文档。 I can see that data exists, however I cannot see my app folder when I navigate to Finder > iCloud Drive.
我可以看到数据存在,但是当我导航到Finder> iCloud Drive时,我看不到我的app文件夹。 What I need to do is drop files into my app folder in iCloud Drive on my Mac, so that they can be read in via my application.
我需要做的是将文件放入我的Mac上的iCloud Drive中的app文件夹中,以便可以通过我的应用程序读取它们。 I read that simply appending the 'Documents' folder to the end of my ubiquity URL would make it visible in finder, however this hasn't worked.
我读到只是将'Documents'文件夹附加到我的ubiquity URL的末尾会使它在finder中可见,但是这没有用。 This leads me onto question 3:
这引出了我的问题3:
Its taken a little while but I've managed to figure this out myself, I'll post the resolution for anyone else struggling with this. 它花了一点时间,但我已经设法自己解决这个问题,我会发布解决方案给其他任何正在努力解决这个问题的人。
The application will create its own iCloud container which will be visible when managing iCloud documents, but by default wont be visible in the iCloud Drive folder on Mac or icloud.com. 该应用程序将创建自己的iCloud容器,该容器在管理iCloud文档时可见,但默认情况下在Mac或icloud.com上的iCloud Drive文件夹中不可见。 With some additions to the info.plist file, the application's iCloud folder can be made visible in Finder (see answer 3).
通过添加info.plist文件,可以在Finder中显示应用程序的iCloud文件夹(参见答案3)。
When testing on the simulator, I couldn't see any synced documents at all, after moving to an iPad I could see the documents from my app and other apps such as TextEdit. 在模拟器上进行测试时,我根本看不到任何已同步的文档,移动到iPad后我可以看到我的应用程序和其他应用程序(如TextEdit)中的文档。 This leads me to believe that iCloud functionality doesn't work properly on the iOS Simulator.
这让我相信iCloud功能在iOS模拟器上无法正常工作。 Maybe it will work by manually adding the files to the appropriate container folder - but in reality thats not good enough for testing fully.
也许它可以通过手动将文件添加到适当的容器文件夹来工作 - 但实际上这不足以完全测试。
As mentioned above, making the app's iCloud folder public requires some additions to the info.plist file. 如上所述,将应用程序的iCloud文件夹公开需要添加一些info.plist文件。 In Xcode 6.3.2 this will look as follows (setting the blurred bundle identifier and ContainerName as appropriate and also incrementing the Bundle Version and Bundle Version String respectively):
在Xcode 6.3.2中,这将如下所示(根据需要设置模糊的包标识符和ContainerName,并分别增加Bundle Version和Bundle Version String):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.