DocumentGroupLaunchScene corrupts the toolbar for DocumentGroup content views.

The sample code provided in "Building a document-based app with SwiftUI" (https://developer.apple.com/documentation/swiftui/building-a-document-based-app-with-swiftui) does not work as expected.

The DocumentGroup/StoryView toolbar does not appear for documents opened in the App.

By removing the DocumentGroupLaunchScene block from the App the toolbar does appear and works as expected - but of course the App's DocumentGroupLaunchScene customizations are lost.

I've tested this on 18.0 devices, as well as production 18.0 and 18.1 beta 6 simulators.

If I modify the StoryView by wrapping the content in a NavigationStack I can make some progress - but the results are unstable and hard to pin down - with this change the first time a document is opened in the WritingApp the toolbar appears as expected. When opening a document subsequently the toolbar is corrupted.

Please is this a bug or is there a good example of incorporate both DocumentGroupLaunchScene customizations at the App level and retina the toolbar in documents presented via DocumentGroup?

@chrisfromboulder I'd greatly appreciate it if you could open a bug report, and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

I've now reported this in bug report FB15567398.

DocumentGroup is so broken. Every new Xcode seem to produce just more and more issues with it.

Due DocumentGroup the toolbar or my app is totally broken! Uninstall-rate is about 80%! Please fix DocumentGroup!

No response on filing FB15567398 - and two months on and the bug remains. It would be great to get some feedback and an indication that something will be done to make DocumentGroup do what it says on the tin. This is blocking me from going fully SwiftUI for an App - so I am stuck with Frankenstein mode for a while longer.

Do we have any update on this DocumentGroupLaunchScene toolbar issue? I have a similar issue on iOS 18.4 RC and RC 2. When my SwiftUI document-based app opened the first time, it had duplicated toolbar items. The second time, it opened with another document, it had more duplicated toolbar items with the wrong document name (first document name). Toolbar items flickered from time to time and didn't respond to the tap. This issue can be re-produced in the sample code (Building a document-based app with SwiftUI). I have submitted feedback for this, FB17025216.

I have the exact same issue of @ykroh1 . Each time I open or create a new document, a new toolbar gets added to the navigation bar. It is pretty much unusable and we can’t ship documents app in this state with SwiftUI. please fix this bug.

It seems that with Xcode 16.4 and iOS 18.5 beta 4 SDK Apple has solved this issue (even if there are no evidence in the release note)

@ykroh1 @chrisfromboulder

This sounds promising - hopefully both will be GA in the next couple of weeks.

I recently noticed that - as of Xcode 16.3 and iOS 18.4 - when using DocumentLaunchScene with DocumentGroup, the document name in the navigation bar INCORRECTLY adopts the name of the first file opened after starting the App for ALL subsequent files opened. This occurs with or without wrapping the contentView in with NavigationStack{ ContentView(...) }

All works fine on macOS because I remove DocumentGroupLaunchScene with #if os(macOS) #endif.

The entire scenario can be repeated easily using Apple's "Building a document-based app with SwiftUI" sample code.

Tra la la.

I uploaded a few apps and noticed the title being pulled from the first app opened. If I build using Xcode 16.4, would that solve the issue or should we just wait for the 18.5 GA?

I have this problem too. But also how do you use DocumentGroupLaunchScene with the prepareDocument closure? It's crashing for me when I do something like this:

DocumentGroupLaunchScene(Text("MyApp")) {
		NewDocumentButton("New")
		NewDocumentButton("New...", contentType: .myDocument) {
			try await withCheckedThrowingContinuation { continuation in
				documentCreationContinuation = continuation
					showTemplatePicker = true
			}
		}
		.fullScreenCover(isPresented: $showTemplatePicker) {
				TemplatePicker(documentCreationContinuation: $documentCreationContinuation)
			}
		} background: {
			Image("BackgroundImage")
				.resizable()
		}
}

These problems appear solved on iOS 18.5 GA.

Building with Xcode 16.3 on macOS 15.5 GA and running live on iOS 18.5 GA:

  1. No more duplication of toolbar items( the NavigationStack wrapper workaround is no longer needed)
  2. The Toolbar now correctly adopts name of the file you open each time

Of course I'll be retesting as soon as Xcode 16.4 is available with an iOS 18.5 simulator.

This is a huge relief as these problems started with iOS 18.0 and have been blocking me from adopting DocumentLaunchScene and converting 100% to SwiftUI.

I've not used the "prepare document closure" so cannot comment - sorry.

DocumentGroupLaunchScene corrupts the toolbar for DocumentGroup content views.
 
 
Q