DocumentGroup double back button fix

Dec 10, 2022 swiftui

If you are building DocumentGroup-based apps in SwiftUI, you may have noticed that apps that worked fine in Xcode 15 now show two back buttons when being built with Xcode 16.

A DocumentGroup screen that shows two back buttons

While I’m not sure what’s causing this, you can fix this bug by applying .toolbarRole(.automatic) to the document group content view.

Since this is only available in iOS 16, this extension may be convenient if you target older versions of iOS:

extension View {

    func withAutomaticToolbarRole() -> some View {
        if #available(iOS 16.0, *) {
        } else {

You can now adjust your document group content to remove the extra back button:

struct MyApp: App {
    var body: some Scene {
        DocumentGroup(newDocument: MyDocumentType()) { file in
            MyDocumentView(file: file)

Hope this helps…and fingers crossed that Apple fixes this bug soon!