iCloud user directory

I was able to use file manager with url(forUbiquityContainerIdentifier:) method to get the iCloud root directory for my app, but I need to save documents generated by my app in a directory that the user can access freely from Finder on a Mac or File Manager on Windows. What do I need to know to be able to do that?

Replies

You want to be putting the documents into iCloud Drive, which will then show up for users on their Mac or Windows machines (as well as other iOS devices). I'd recommend having a look at Designing for Documents in iCloud, TN2348: Technical Note TN2348: iCloud Drive Migration, and https://support.apple.com/HT204283. There are also some WWDC videos from the last couple years that you can dig into.


Is that what you're looking for?

That sounds like what I need. I wasn't sure exactly what I was looking for.

There's a lot in those documentation resources. Can you pinpoint to me exactly what to look for that would instruct me how to save a file to iCloud out of the app sandbox or icloud container where any app on any device can access it?

Is there by chance a "public" iCloud Container in iCloud or iCloud Drive that my app can access that would allow files in this public container to be accessed by a user account using other apps like a text file editor?

Yes and no. The "other app" needs to be programmed (by you) to access the file on CloudKit.


You will want to explore CouldKit JS

https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/Introduction/Introduction.html

https://developer.apple.com/reference/cloudkitjs

Are you saying that if I create an iOS app that creates a text file that I can't open that text file even with TextEdit?

I believe there is no way that the 'app' TextEdit can access that file. I believe that you can write an iOS or MacOS app that can access that file either directly using iCloud Document Storage APIs or through the web using CloudKit JS.

A few quick points to hopefully get this conversation back on track. If you're just starting out building a document-based app you absolutely want to be using UIDocument. It handles most of the dirty work automatically for you.


I would also highly recommend you watch this session from WWDC 2015 about building document-based apps: https://developer.apple.com/videos/play/wwdc2015/234/


and the very helpful ShapeEdit sample code that goes along with that session: https://developer.apple.com/library/content/samplecode/ShapeEdit/Introduction/Intro.html


From what you've described it sounds like iCloud Drive would be what you want. If you're looking to extend the access to your files to include websites then CloudKit might be a solution, but given what you've said here I think that's not what you're looking for.

I found documentation that contradicts what you said. It's the Document Picker Programming Guide. It says my app can access a public directory in iCloud. Here it is https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/DocumentPickerProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40014451-CH1-SW5


It says:


The Document Picker Enables Sharing Documents Between Apps

The document menu view controller displays a list of document providers available on the device. Each provider grants access to a container outside your app’s sandbox. For example, iCloud Drive lets users reach into the public iCloud container or into another app’s iCloud container and access the files stored there.


However, I've found documentation supporting your claim. There seems to be contradictory documentation. Can you clarify this?