简体   繁体   English

我可以通过Mac在iCloud中添加文件,并在iOS应用程序中使用该文件

[英]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. 这让我质疑一个问题。

  1. Does my application only have access to files that are saved to iCloud by the application itself. 我的应用程序是否只能访问应用程序本身保存到iCloud的文件。 Or, for example, if I add the CSV files to the iCloud Drive via Finder on my iMac, can I then access those files from within my application, if so how would I go about this? 或者,例如,如果我通过iMac上的Finder将CSV文件添加到iCloud Drive,我是否可以从我的应用程序中访问这些文件,如果是这样我将如何进行此操作?

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

  1. Does iCloud Document Storage work on the iOS Simulator, if so is there anything special I need to do to initiate a sync to grab the CSV files I placed in my iMac's iCloud Drive folder. iCloud文档存储是否可以在iOS模拟器上运行,如果有的话,我需要做些什么来启动同步以获取我放在iMac的iCloud Drive文件夹中的CSV文件。

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:

  1. What do I need to do to make my applications specific iCloud folder visible in the iCloud Drive folder within my Mac's Finder window? 如何在Mac的Finder窗口中的iCloud Drive文件夹中显示我的应用程序特定的iCloud文件夹?

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. 它花了一点时间,但我已经设法自己解决这个问题,我会发布解决方案给其他任何正在努力解决这个问题的人。

  1. 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)。

  2. 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. 也许它可以通过手动将文件添加到适当的容器文件夹来工作 - 但实际上这不足以完全测试。

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

相关问题 如何从 iOS Swift 应用程序中读取 iCloud Drive 桌面文件夹中的 pdf 文件? - How do I read a pdf file in my iCloud Drive Desktop folder from within an iOS Swift app? 如何使用iCloud在我的应用程序之间同步.zip文件? - How can I use iCloud to synchronize a .zip file between my apps? 我可以使用iCloud同步NSUserDefaults plist文件 - Can I use iCloud to sync the NSUserDefaults plist file 如何将外部 jar 文件添加到本机应用程序中,并将其用作 javascript 文件中的插件,用于 android 和 iOS - How can I add the external jar file into react native application and use as a plugin into the javascript file for both android and iOS 我可以通过iOS应用程序将文件写入公用文件夹吗? - Can I write a file in a public folder from my iOS application? 如何在我的iOS应用程序中保留HTML文件? - How can I persist an HTML file in my iOS application? 我可以通过拖放从Mac接受文件到iOS模拟器吗? - Can I accept a file via Drag & Drop from the Mac to the iOS Simulator? 如何在不使用Xcode的情况下将iCloud Documents功能添加到我的应用程序中? - How can I add iCloud Documents capabilities to my application without using Xcode? iOS应用程序可以在不创建OS X应用程序的情况下通过蓝牙与Mac上的Java应用程序通信吗? - Can an iOS application communicate with a Java application on my Mac via bluetooth without creating an OS X application? 我有一个iCloud文件的公共URL,如何在iOS中下载DIRECT链接? - I have a public URL for an iCloud file, how can I get the DIRECT link to download in iOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM