Article

Creating File Providers for Multiple Versions of iOS

Create File Provider extensions that support different versions of iOS.

Overview

In iOS 11 and later, the file provider must enumerate its contents, provide additional information about the contents, and handle standard user actions (for example, delete, rename, and move). With these features, the system can provide a standard user interface for browsing your file provider's content.

In iOS 10 and earlier, the file provider was only half of the Document Provider extension. It acted as the back end, ensuring that all the URLs returned by the document provider were backed by files on disk.

The file provider was only responsible for managing access to the underlying files. It intercepted coordinated-read and coordinated-write operations from the host app, so you could download and upload files as needed. A second extension—the Document Picker View Controller extension—provided the user interface.

Because of these changes, the tasks involved in implementing a File Provider extension differ depending on which version of iOS you're targeting.

Supporting iOS 11 and Later

When creating a file provider that targets iOS 11 or later:

  • You no longer provide the Document Picker View Controller extension. The system now provides a standard user interface instead.

  • If you're updating an existing File Provider extension, be sure to set the NSExtensionFileProviderSupportsEnumeration key to YES in your extension's Info.plist file. If you're creating a new extension, Xcode automatically sets this key for you.

  • You must override all of the NSFileProviderExtension class's methods—including new methods that handle item enumeration, provide item descriptions, and respond to user actions. You don't need to override the deprecated methods.

  • Keep in mind that the following NSFileProviderExtension methods are deprecated in iOS 11: placeholderURL(for:), writePlaceholder(at:withMetadata:), documentStorageURL, and providerIdentifier. These methods have moved to the new NSFileProviderManager class.

Supporting iOS 10 and Earlier

When creating a file provider that targets a version of iOS earlier than iOS 11:

For more information, see Document Provider.

Accessing File Providers from the Host App

In the host app, file providers supporting iOS 10 and earlier result in a different browsing experience than you have with file providers supporting iOS 11 and later:

For file providers supporting iOS 10 and earlier, the document picker presents the user interface defined by the corresponding Document Picker View Controller extension.

For file providers supporting iOS 11 and later, the document picker presents the standard browser interface. This interface is the same one used by the UIDocumentBrowserViewController class.