About the Document Picker
The document picker feature lets users select documents from outside your app’s sandbox. These include documents stored in iCloud Drive and documents provided by a third-party extension. Users can open these documents directly, editing them in place. This access simplifies sharing documents between apps and enables more complex workflows. For example, users can easily edit a single document using multiple apps.
At a Glance
The document picker feature give users an unprecedented amount of freedom when it comes to accessing and sharing their documents.
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.
The document picker view controller lets your app import or open files from a particular document provider, uploading and downloading local copies as needed. Apps can also export or move their own documents into these external storage areas.
Sharing Documents Introduces Added Complexity That Your App Must Handle
Many of these sharing operations let users interact with their documents in radically new ways. As a result, users have greater flexibility when it comes to working with their documents. Because this flexibility also introduces additional complexity, your app needs to be able to handle these additional complications with grace and poise.
Enabling iCloud Drive Support Provides Access To Your Documents
If you want to let other apps access files stored in your iCloud container, you must enable iCloud Drive support.
Before your app can use the document picker, you must turn on the iCloud Documents capabilities in Xcode. For more information about iCloud Documents, see Designing for Documents in iCloud in iCloud Design Guide.
Import and export operations simply make copies of existing files. They are relatively easy to use and require only standard app development skills: working with the file system, reading and writing documents, and presenting view controllers.
In contrast, open and move operations introduce a considerable amount of complexity. These operations allow you to access resources outside your app’s sandbox, and more than one process may attempt to read or write to these files concurrently. Before implementing one of these options, familiarize yourself with file coordinators, file presenters, and security-scoped URLs.
For more information about security-scoped URLs, see Bookmarks, Security Scope, and Start/Stop Semantics in NSURL Class Reference.
For more information about file coordinators and file presenters, see The Role of File Coordinators and Presenters in File System Programming Guide.
If you would like additional information on creating your own Document Provider extensions, see Document Provider in App Extension Programming Guide