ToolbarItem has a bug in XCode 15 beta 8.

When I run the following code on my iPad and select an item in the sidebar, the ToolbarItem button shows up, but when I go to the home screen and return to the app, the ToolbarItem button disappears.

struct ContentView: View {
    
    @State var selection: Int? = nil
    
    var body: some View {
        NavigationSplitView {
            List(selection: $selection) {
                ForEach(0...10, id: \.self) { value in
                    NavigationLink(value: value) {
                        Text("\(value)")
                    }
                }
            }
        } detail: {
            ZStack {
                Text("Select : \(selection ?? -1)")
            }
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Button {
                    } label: {
                        Text("ToolbarItem")
                    }
                }
            }
        }
    }
}

Please file a bug report at https://feedbackassistant.apple.com with this and post the feedback number here!

In the meantime, try using a NavigationStack in the detail column. For example:

    } detail: {
            NavigationStack {
                ZStack {
                    Text("Select : \(selection ?? -1)")
                }
                .toolbar {
                    ToolbarItem(placement: .topBarTrailing){
                        Button {
                        } label: {
                            Text("ToolbarItem")
                        }
                    }
                }
            }
        }
ToolbarItem has a bug in XCode 15 beta 8.
 
 
Q