iCloud Drive Documents — how-to
Starting iOS 8.0 application can store files on iCloud Drive. That’s great, but how do I enable it for my app? I went through that, so you don’t have to.
Setup
Enable iCloud Documents with Xcode, from tab Capabilities
Go to Info.plist of you application and add something similar to this
as described here. It’s necessary to add it for every container supported by the application. Caution: here is “iCloud.” prefix and it is important to have it this way.
Documents directory
Create “Documents” subdirectory by your own! It’s not there automatically. Create it on ubiquitous container like this:
then put all files inside this folder. This is very important!
Local Documents vs iCloud Documents
First of all… I have to remember that there are two Documents. Local Documents and iCloud Documents. Local Documents is directory accessible with iTunes File Sharing, while iCloud Documents is accessible from iCloud Drive. Because I read iCloud Drive as replacement for iTunes File Sharing soon, I found this two “Documents” thing confusing.
If I want to make local files (transferred previously to the application with iTunes) accessible with iCloud Drive, I have to copy them to iCloud from my app manually. For example like this:
Final
Finally reinstall application on device. Starting now, application will show among other applications on you iCloud Drive.
Thats pretty much all. You welcome.
Troubleshooting
If something went wrong, fortunately I can do debugging. There is little and powerfull tool that come to the rescue, it’s brctl. Just open Terminal.app, run this command:
and see what appear on terminal, I’ll see something similar to this
from this point on I can see live what is going on under the hood, what files are downloaded (if they are downloaded) etc.
If I want to see all iCloud containers I go to “Mobile Documents” located inside user Library directory, from Terminal:
$ cd ~/Library/Mobile\ Documents; ls -a
this two point are very useful, and most efficient to do troubleshooting of iCloud stuff.
PS. Next version of Privacy will support iCloud Drive for public keys files.
PS 2. You may want to check my other posts here.