NavigationSplitView issues in iOS 18 and 18.1

Hello,

In our current project we are using NavigationSplitView in the following way:

    var body: some View {
        NavigationSplitView(
            sidebar: {
                ListView()
            },
            detail: {
                DetailsView()
            }
        )
        .navigationBarHidden(true)
        .navigationSplitViewStyle(.automatic)
        .introspectSplitViewController { splitViewController in
            splitViewController.preferredDisplayMode = .oneOverSecondary
            splitViewController.maximumPrimaryColumnWidth = 500
            splitViewController.preferredPrimaryColumnWidthFraction = 1
        }
    }
}

And in iPhone the DetailsView() is pushed using the navigationDestination modifier:

    .navigationDestination(isPresented: $isShowingDetailsScreen) {
        DetailsView()
            .navigationBarHidden(true)
    }

where isShowingDetailsScreen is updated through a button click:

    Button() {
        self.isShowingDetailsScreen = true
    }

This works perfectly in iOS versions prior to 18. However starting from this version the button click no longer presents the view desired. Below is what happening in the latest iOS versions:

  • iOS 18: This mechanism is broken altogether, it does not work at all.
  • iOS 18.1: This mechanism is partially broken, when clicking on the button the DetailsView is not presented, however since the page also contains other reactive views, any time one of them is changed through a state change after clicking on that button, the DetailsView is presented.

Does anyone faced an issue like this with the new iOS and if so is there any workaround for now? Because this seems to be a bug caused by changes in SwiftUI and shouldn't persist for long.

@maazarou Could you please provide a small test project that reproduces the issue so that I could investigate it. If you're not familiar with preparing a test project, take a look at Creating a test project.

@DTS Engineer Hello, I've created a test project that reproduces the issue in github. Note that the issue is not actually reproducible with only what I've described initially, it seems that it comes from the fact that we are using NavigationSplitView inside a NavigationStack.

I hope the project will make it clear.

I have the same issue. As soon as I have a NavigationStack that wraps around a NavigationSplitView, the NavigationStacks within it don't function correctly.

However, if I return to the Home screen and go back to the app, the navigation works as expected.

This behavior works fine on iOS 17..

Here is the code that allows you to reproduce the problem:

extension MainView {
    struct NavigationDestination {
        struct SecondView: Hashable {
        }
    }
}

struct MainView: View {
    @State private var navigationPath: NavigationPath = NavigationPath()

    var body: some View {
        NavigationStack(path: $navigationPath) {
            VStack {
                Button {
                    navigationPath.append(MainView.NavigationDestination.SecondView())
                } label: {
                    Text("First Navigation")
                }
            }
            .navigationDestination(for: MainView.NavigationDestination.SecondView.self) { _ in
                SecondView()
                    .navigationTitle("DetailView")
            }
        }
    }
}


extension SecondView {
    struct NavigationDestination {
        struct Detail: Hashable {
        }
    }
}

struct SecondView: View {
    var body: some View {
        NavigationSplitView {
            List {
                Text("test")
            }
        } detail: {
            NavigationStack {
                VStack {
                    NavigationLink(value: SecondView.NavigationDestination.Detail()) {
                        Text("test")
                    }
                }
                .navigationDestination(for: SecondView.NavigationDestination.Detail.self) { subItem in
                    Text("Detail")
                }
            }
        }
    }
}
NavigationSplitView issues in iOS 18 and 18.1
 
 
Q