I have two separate Xcode projects that I'm using to learn SwiftUI:
- A true macOS project (not Catalyst) on Mac.
- An iOS project (iPhone).
The following code creates a simple
NavigationView
with master-detail views:import SwiftUI
struct ListView : View {
var body: some View {
NavigationView {
List() {
NavigationButton(destination: Text("detail 1")) {
Text("row 1")
}
NavigationButton(destination: Text("detail 2")) {
Text("row 2")
}
}
}
}
}
#if DEBUG
struct ListView_Previews : PreviewProvider {
static var previews: some View {
ListView()
}
}
#endif
It works as expected on iOS 👍
But on the macOS project the same code as above doesn't work the same way
When I launch the app on Mac, I get this window
And when I click on any row, the detail view just collapses/disappears, never showing me detail view.
Any ideas how to fix this? Maybe I'm missing something? Or perhaps this is just a bug?