I am writing a document-based app for macOS using SwiftUI. I want the File menu's New Document command to show a template picker/wizard, and then let the wizard create the document.
How do I structure this? Is there documentation? Examples?
I tried this pattern
@main struct DocDemoApp: App {
var body: some Scene {
WindowGroup { NewDocWizard() }
DocumentGroup(newDocument: { DocDemoDocument() }) {
ContentView(document: $0.document)
}
}
}
The NewDocWizard calls newDocument({ DocDemoDocument() }). But the WindowGroup makes a File > New Window command while DocumentGroup makes the File > New Document command. I need just New Document and it should show the NewDocWizard.