The principal class for the File Provider extension.


class NSFileProviderExtension : NSObject


To create a File Provider extension, subclass this class and override all of its methods. When implementing your NSFileProviderExtension subclass, remember:

  • You must override all of the extension's methods (except the deprecated methods), even if your implementation is only an empty method.

  • Use these methods to provide access to the documents and folders managed by your file provider.

  • Don't call super in your method implementations.


Working with Items and Persistent Identifiers

func persistentIdentifierForItem(at: URL) -> NSFileProviderItemIdentifier?

Returns a unique identifier for the given URL.

func urlForItem(withPersistentIdentifier: NSFileProviderItemIdentifier) -> URL?

Returns the URL for a given persistent identifier.

func item(for: NSFileProviderItemIdentifier) -> NSFileProviderItem

Returns a description of the item associated with the persistent identifier.

struct NSFileProviderItemIdentifier

A unique identifier for an item managed by the File Provider extension.

Managing Shared Files

func itemChanged(at: URL)

Tells the File Provider extension that a document has changed.

func providePlaceholder(at: URL, completionHandler: (Error?) -> Void)

Triggers the creation of a placeholder for the given URL.

func startProvidingItem(at: URL, completionHandler: (Error?) -> Void)

Provides an actual file on disk for a placeholder.

func stopProvidingItem(at: URL)

Tells the File Provider extension that a given document is no longer being accessed.


Handling Actions

Providing Support for User-Driven Actions

Override methods to handle user-initiated actions.

Managing Domains

var domain: NSFileProviderDomain?

The domain managed by this file provider object.

Working with Services

func supportedServiceSources(for: NSFileProviderItemIdentifier) -> [NSFileProviderServiceSource]

Return an array of service sources that let the host app perform actions associated with the specified item.

protocol NSFileProviderServiceSource

A service that provides a custom communication channel between the host app and the File Provider extension.

Managing Placeholders

These methods have been deprecated and moved to the NSFileProviderManager class.

class func placeholderURL(for: URL) -> URL

Returns a placeholder URL for a given document URL.

class func writePlaceholder(at: URL, withMetadata: [URLResourceKey : Any])

Writes a document placeholder with the provided metadata.


Accessing the Document Storage

These methods have been deprecated and moved to the NSFileProviderManager class.

var documentStorageURL: URL

The root URL for all shared documents.

var providerIdentifier: String

A purpose identifier for coordinated reads and writes.



Inherits From

Conforms To

See Also

First Steps

class NSFileProviderManager

A manager object that you use to communicate with the file provider from either your app or your File Provider extension.