SwiftUI toolbar bug on Monterey

The code below works normally on macOS Big Sur. However, after compiling with Xcode 13 and running in Monterey, an error occurs.

This is an issue with "toolbar".

If I comment out the toolbar part of ProfileView, it works without error.

What part is wrong? Or is it a bug in Xcode13?

If the way you use the toolbar changes in the future, please let me know the correct way.

PLATFORM AND VERSION

  • macOS Monterey 12.0 beta (21A5506j)
  • Xcode 13.0 beta 5 (13A5212g)

STEPS TO REPRODUCE

  1. Run Xcode 13.0 beta 5
  2. Create macOS project
  3. Paste the above code into ContentView & ProfileView.
  4. Run debug
  5. Error when selecting "Profile 1" from the list
struct ContentView: View {
    var body: some View {
        NavigationView {
            ScrollViewReader { scrollProxy in
                List {
                    ForEach([1,2,3], id: .self) { id in
                        NavigationLink("Profile (id)", destination: ProfileView())
                    }
                }
                .navigationTitle("Profile List")
                .toolbar {
                    ToolbarItemGroup(placement: .confirmationAction, content: {
                        Button(action: {
                            print("Settings...")
                        }) {
                            Image(systemName: "gearshape.fill")
                        }
                        Button(action: {
                            NSApp.keyWindow?.firstResponder?.tryToPerform(#selector(NSSplitViewController.toggleSidebar(_:)), with: nil)
                        }, label: {
                            Image(systemName: "sidebar.left")
                        })
                    })
                }
            }
        }
    }
}

struct ProfileView: View {
    var body: some View {
        ZStack {
            VStack {
                Text("ProfileView")
            }
        }
        .toolbar {
            ToolbarItemGroup(placement: .confirmationAction, content: {
                Button("Save", action: {
                    print("Save...")
                })
            })
        }
    }
}
SwiftUI toolbar bug on Monterey
 
 
Q