One Logo Pool Ball
SwiftUI · IOS API REFERENCE

DocumentReader

protocol · iOS 27.0+ · SDK 27.1

protocol DocumentReader<Snapshot>

A type that reads a document's content from a file. SwiftUI calls your document's ``ReadableDocument/reader(configuration:)`` method to obtain a `DocumentReader`, then invokes ``read(from:progress:)`` in the background with coordinated file access. The returned snapshot is delivered to ``ReadableDocument/apply(snapshot:previous:)`` on the main actor. Use ``FileWrapperDocumentReader`` for cases that don't require custom file read logic. Implement a `DocumentReader` when you need direct URL access for frameworks like Core Graphics, AVFoundation, or PDFKit: struct ImageReader: DocumentReader { @concurrent func read(from source: URL, progress: consuming Subprogress) async throws -> sending CGImage { guard let provider = CGDataProvider(url: source as CFURL), let image = CGImage( jpegDataProviderSource: provider, decode: nil, shouldInterpolate: true, intent: .defaultIntent ) else { throw CocoaError(.fileReadCorruptFile) } return image } } SwiftUI provides the document's file URL as the reader's source.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →