File Provider
An extension other apps use to access files and folders managed by your app and synced with a remote storage.
Overview
If your app focuses on providing and syncing user documents from remote storage, you can implement a File Provider extension to give users access to those documents when they’re using other apps. If you just need to share local documents, see Share files locally below.
[Image]
The framework has two different starting points for building your File Provider extension.
- NSFileProviderReplicatedExtension
The system manages the content accessed through the File Provider extension. Available in macOS 11+ and iOS 16+.
- NSFileProviderExtension
The extension hosts and manages the files accessed through the File Provider extension. Available in iOS 11+.
The replicated extension takes responsibility for monitoring and managing the local copies of your documents. The file provider focuses on syncing data between the local copy and the remote storage—uploading any local changes and downloading any remote changes. For more information, see Replicated File Provider extension.
The nonreplicated extension manages a local copy of the extension’s content, including creating and managing placeholders for remote files. It also syncs the content with your remote storage. For more information, see Nonreplicated File Provider extension.
Share files locally
You don’t need a File Provider extension to allow access to documents that your app stores locally.
In iOS, to give other apps access to the files in your Documents directory, set the following keys in your app’s Info tab or its Info.plist file. For document browser-based apps, set the UISupportsDocumentBrowser key. For all other apps, set both the UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace keys.
After you set these keys, other apps can 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 UIDocumentBrowserViewController class.
Topics
Essentials
Extension types
Extension management
Provided items
NSFileProviderItemNSFileProviderItemProtocolNSFileProviderItemIdentifierNSFileProviderItemCapabilitiesNSFileProviderTypeAndCreator
Cloud search
Domains
Errors
NSFileProviderErrorNSFileProviderError.CodeNSFileProviderErrorDomainNSFileProviderErrorItemKeyNSFileProviderErrorNonExistentItemIdentifierKeyNSFileProviderErrorCollidingItemKey