Implement a File Provider extension so that other apps can access the documents and directories stored and managed by your containing app.
- iOS 11.0+
- macOS 10.15+
- Mac Catalyst 13.0+
If your app is primarily focused on storing and managing user documents, you can implement a File Provider extension to give users access to their content while they're using other apps.
The File Provider extension:
Creates placeholders for remote files that you download only as needed.
Intercepts coordinated reads from the host app, so that the file can be downloaded or updated from the remote server before the read occurs.
Triggers a notification after coordinated writes from the host app, so that the extension can upload the changes to the remote server as needed.
Enumerates the stored documents and folders.
Executes actions—such as importing, moving, renaming, or deleting items—on the stored documents and folders.
Other apps access the stored documents using either the
UIDocument classes. These classes provide a standard user interface for browsing and interacting with the stored documents and folders. However, you can add custom actions to the browser's context menu using the FileProviderUI framework.
You can also define custom message interfaces for your file provider. Use these interfaces to add features that aren't provided by the base API. For more information, see
Does Your App Need a File Provider?
In general, implement a File Provider extension only if your app provides access to documents stored on a remote server. You don't need a File Provider extension to provide access to documents stored locally.
To give other apps access to the files in your
Documents directory, just set the proper keys in your app's
Info file. You can either set the UISupportsDocumentBrowser key (for document browser-based apps), or set both the UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace keys.
These keys enable other apps to open and edit the contents of your
Documents directory in place. Your files also appear in both the Files app and the document browser. For more information, see the
Supporting Drag and Drop
If your application acts as a drag source for remote documents, override your
register method, and return the URL for the item being dragged. This URL is the value returned by your extension's
URLFor method. The URL may refer to a local file or (if you don't have a local copy) to the file's placeholder.
If the URL points to a placeholder, the system calls your File Provider extension's
start method, giving you the opportunity to download the file.