<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DocumentGroup/init(viewer:makeReadableDocument:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13DocumentGroupVAA11Observation10ObservableRzAA08ReadableC0Rz10Foundation3URLV6ReaderAaFP_6SourceRTzrlE6viewer04makegC0ACyxq_Gq_xc_xAA24URLDocumentConfigurationC_AA0C15CreationContextVtYaKScMYcctcfc"
  },
  "title" : "init(viewer:makeReadableDocument:)"
}
-->

# init(viewer:makeReadableDocument:)

Creates a document group capable of opening and viewing read-only
documents.

```
nonisolated init(@ContentBuilder viewer: @escaping (Document) -> Content, makeReadableDocument: @escaping @MainActor (URLDocumentConfiguration, DocumentCreationContext) async throws -> Document)
```

## Parameters

`viewer`

The viewing UI for the provided document.

`makeReadableDocument`

A closure that creates the document
instance. Throw `CancellationError` to indicate that document
opening was cancelled.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)