NewDocumentButton in DocumentGroupLauchScene crashes for SwiftData Document-Based App

I have a SwiftData document-based app. It is initialized like this:

@main
struct MyApp: App {
	@State private var showTemplatePicker = false
	@State private var documentCreationContinuation: CheckedContinuation<URL?, any Error>?

	var body: some Scene {
		DocumentGroup(editing: .myDocument, migrationPlan: MyMigrationPlan.self) {
			CanvasView()
		}
		DocumentGroupLaunchScene(Text("My App")) {
			NewDocumentButton("New", contentType: .canvasDocument) {
				try await withCheckedThrowingContinuation { continuation in
					documentCreationContinuation = continuation
					showTemplatePicker = true
				}
			}
			.fullScreenCover(isPresented: $showTemplatePicker) {
				TemplateView(documentCreationContinuation: $documentCreationContinuation)
			}
		} background: {
			Image("BoardVignette")
				.resizable()
		}
	}
}

extension UTType {
    static var canvasDocument: UTType {
        UTType(importedAs: "com.example.MyApp.canvas")
    }
}

Pressing the New button crashes with:

#0	0x00000001d3a6e12c in (1) suspend resume partial function for closure #1 () async -> () in SwiftUI.IdentifiedDocumentGroupDocumentCreation.createNewDocument(with: SwiftUI.IdentifiedDocumentGroupConfiguration, url: Swift.Optional<Foundation.URL>, newDocumentProvider: Swift.Optional<SwiftUI.AsyncNewDocumentProvider>, _: (Swift.Optional<SwiftUI.PlatformDocument>) -> ()) -> () ()

All sample code that I've seen uses a FileDocument but SwiftData's setup doesn't have one so it's not completely clear how you should be using NewDocumentButton with a SwiftData file.

The crash happens even before my prepareDocumentURL handler is called (I set a breakpoint and it never stops). My hunch is that the crash is because it's not able to match my contentType to a Document. Can anyone at Apple help? I don't think this use-case has been documented well.

I modified the SwiftDataFlashCardsSample app from WWDC and it has the same problem.

Feedback filed: FB17589830

NewDocumentButton in DocumentGroupLauchScene crashes for SwiftData Document-Based App
 
 
Q