I found out that in Xcode 16+ using canCollapseFromWindowResize
with canCollapse
did the trick and you cannot hide the sidebar anymore by dragging it on macOS.
NavigationSplitView {
Text("sidebar")
.toolbar(removing: .sidebarToggle)
} detail: {
Text("detail")
}
.introspect(.navigationSplitView, on: .macOS(.v13,.v14,.v15)) { splitview in
if let delegate = splitview.delegate as? NSSplitViewController {
delegate.splitViewItems.first?.canCollapse = false
delegate.splitViewItems.first?.canCollapseFromWindowResize = false
}
}
I don't really understant why @yu-zhao got down voted because that solution worked until the newest version of macos and xcode.