Contents

Documents

Enable people to open and manage documents.

Overview

Create a user interface for opening and editing documents.

[Image]

Use the ReadableDocument and WritableDocument protocols to define your document model. They give you direct access to file URLs, integrate with Swift concurrency, and support progress reporting. For simpler documents, you can use the FileDocument protocol, which handles serialization through a FileWrapper. You can also use SwiftData-backed documents using an initializer like init(editing:contentType:editor:prepareDocument:).

SwiftUI supports standard behaviors people expect from a document-based app, appropriate for each platform, like multiwindow support, open and save panels. For related design guidance, see Patterns in the Human Interface Guidelines.

Topics

Creating a document

Storing document data in a value type

Storing document data in a reference type instance

Accessing document configuration

Reading and writing documents

Opening a document programmatically

Configuring the document launch experience

Renaming a document

Deprecated

See Also

App structure