On my iPhone, there's Files app that allows me to browse iCloud Drive etc. For an app I'm writing, I need to know the absolute pathname of this Files folder, or any other folder where I could save a file from the app. How do I find this?


1 Answer 1


I assume you want this information in order to be able to save files there. That is not how it is done (and it won't work). The list of files and folders presented by the Files app is not an actual folder in the file system, but is instead a virtual view that is composed of files stored multiple places in the file system.

To enable use of the Files app, you want to edit your Info.plist file and declare that your app has files that should be made available in the Files app:

If your app is document-based and uses the UIDocumentBrowserViewController class, then you need to create a key named UISupportsDocumentBrowser in the Info.plist file, and set it to YES.

Alternatively, you need to create and set the keys UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace to YES in Info.plist.

If you do the above, the documents that you stored in your app's Documents folder are automatically presented in the Files app.

If you want the path to that Documents folder, you can get it in code like this:

let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let documentsDirectory = urls[0]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .