One Logo Pool Ball
SwiftUI · IOS API REFERENCE

URLDocumentConfiguration

class · iOS 27.0+ · SDK 27.1

@MainActor final class URLDocumentConfiguration

The configuration of an open document that stores its file URL, last modification date, and related metadata. SwiftUI passes a `URLDocumentConfiguration` to the `makeDocument` closure of ``DocumentGroup``. This class is `@Observable` — views and other observers can track changes to ``fileURL`` and other properties. Use ``makeFileCoordinator()`` to perform coordinated reads or writes outside the normal ``DocumentReader``/``DocumentWriter`` flow — for example, to read a single sub-file of a package document on demand: let coordinator = configuration.makeFileCoordinator() var error: NSError? coordinator.coordinate( readingItemAt: pageURL, options: [], error: &error ) { url in let data = try? Data(contentsOf: url) // ... } > Important: Inside ``DocumentReader/read(from:progress:)`` and > ``DocumentWriter/write(content:to:previous:progress:)``, use the > `source` / `destination` URL parameter — not ``fileURL``. The > configuration's URL reflects current state and may differ from > the operation's URL after a Save As or rename.

Members (7)

get · iOS 27.0+

description

TypeScript
get description(): Promise<string>
Swift declaration
nonisolated final var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

get · iOS 27.0+

creationSource

TypeScript
get creationSource(): Promise<(DocumentCreationSource) | null>
Swift declaration
@MainActor final var creationSource: DocumentCreationSource? { get }

The source associated with the button that created this document. On iOS, you can specify the source using a ``NewDocumentButton`` in ``DocumentGroupLaunchScene``: extension DocumentCreationSource { static let scanner: Self = DocumentCreationSource(id: "document-from-scanner") static let template: Self = DocumentCreationSource(id: "document-from-template") } DocumentGroupLaunchScene("Documents") { NewDocumentButton("Scan Document", source: .scanner) NewDocumentButton("New from Template", source: .template) } Use this property to determine which ``NewDocumentButton`` triggered the creation of the current document, allowing you to customize the UI accordingly.

method · iOS 27.0+

makeFileCoordinator

TypeScript
makeFileCoordinator(): Promise<_Foundation_NSFileCoordinator>
Swift declaration
@MainActor final func makeFileCoordinator() -> sending NSFileCoordinator

Creates a file coordinator for coordinated disk access outside the normal read/write flow. Call this every time to get a new coordinator for each separate read or write operation. SwiftUI coordinates file access for ``DocumentReader/read(from:progress:)`` and ``DocumentWriter/write(snapshot:to:previous:progress:)`` automatically. Use this method when you need to access the document's file at other times — for example, to read a single sub-file of a package on demand. Do not reuse coordinators across operations since `NSFileCoordinator` does not conform to `Sendable`.

get · iOS 27.0+

lastContentModificationDate

TypeScript
get lastContentModificationDate(): Promise<(globalThis.Date) | null>
Swift declaration
@MainActor final var lastContentModificationDate: Date? { get set }

The date on which the contents of the document were last modified, if available.

set · iOS 27.0+

lastContentModificationDate

TypeScript
setLastContentModificationDate(value?: (globalThis.Date) | null): Promise<void>
Swift declaration
@MainActor final var lastContentModificationDate: Date? { get set }

The date on which the contents of the document were last modified, if available.

get · iOS 27.0+

fileURL

TypeScript
get fileURL(): Promise<(string) | null>
Swift declaration
@MainActor final var fileURL: URL? { get set }

A URL of the open document if it is saved to disk. Returns `nil` if the document has never been saved.

set · iOS 27.0+

fileURL

TypeScript
setFileURL(value?: (string) | null): Promise<void>
Swift declaration
@MainActor final var fileURL: URL? { get set }

A URL of the open document if it is saved to disk. Returns `nil` if the document has never been saved.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →