We are seeing the same error when trying to hide toolbar in a view inside NavigationSplitView on iPhone 16 Pro Max simulator running iOS 18. This crashes when rotating the phone to landscape when the view is open and toolbar hidden.
We would sometimes want to hide the toolbar in compact mode, but haven't found a good solution yet.
import SwiftUI
enum NavigationDestination: Hashable, Codable {
case home
}
struct ContentView: View {
@State var columnVisibility: NavigationSplitViewVisibility = .all
@State var navigationPath: [NavigationDestination] = []
@ViewBuilder
var sidePanel: some View {
VStack {
Button("Home") {
navigationPath.append(.home)
}
}
}
var body: some View {
ZStack {
NavigationSplitView(
columnVisibility: $columnVisibility,
sidebar: {
sidePanel
},
detail: {
NavigationStack(path: $navigationPath) {
ZStack {}
.navigationDestination(for: NavigationDestination.self) { d in
switch d {
case .home:
HomeView()
}
}
}
}
)
}
}
}
struct HomeView: View {
var body: some View {
VStack {
Text("Home view")
}
.toolbar(.hidden)
}
}