Documents
Enable people to open and manage documents.
Overview
Create a user interface for opening and editing documents using the DocumentGroup scene type.
[Image]
You initialize the scene with a model that describes the organization of the document’s data, and a view hierarchy that SwiftUI uses to display the document’s contents to the user. You can use either a value type model, which you typically store as a structure, that conforms to the FileDocument protocol, or a reference type model you store in a class instance that conforms to the ReferenceFileDocument protocol. You can also use SwiftData-backed documents using an initializer like init(editing:contentType:editor:prepareDocument:).
SwiftUI supports standard behaviors that users expect from a document-based app, appropriate for each platform, like multiwindow support, open and save panels, drag and drop, and so on. For related design guidance, see Patterns in the Human Interface Guidelines.
Topics
Creating a document
Building a document-based app with SwiftUIBuilding a document-based app using SwiftDataDocumentGroup
Storing document data in a structure instance
Storing document data in a class instance
Accessing document configuration
Reading and writing documents
Opening a document programmatically
Configuring the document launch experience
DocumentGroupLaunchSceneDocumentLaunchViewDocumentLaunchGeometryProxyDefaultDocumentGroupLaunchActionsNewDocumentButtonDocumentBaseBox