2
votes

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

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.

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. Which leads me to question one.

  1. Does my application only have access to files that are saved to iCloud by the application itself. 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?

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

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. I've also seen tutorials or screenshots showing that my assumptions of question 1 were correct.

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. I can see that data exists, however I cannot see my app folder when I navigate to Finder > iCloud Drive. 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. 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. This leads me onto question 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?
1

1 Answers

5
votes

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. With some additions to the info.plist file, the application's iCloud folder can be made visible in Finder (see answer 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. This leads me to believe that iCloud functionality doesn't work properly on the iOS Simulator. 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. 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):

enter image description here