Hello,
My app worked perfectly using Xcode 15.4. After updating to Xcode 16, my NavigationStack started to present the same screen twice using the following code:
@EnvironmentObject private var pathSports: NavigationRouteManager
var body: some View {
NavigationStack(path: $pathSports.path) { .... } .environmentObject(pathSports) }
NavigationRouteManager:
import Foundation import SwiftUI
class NavigationRouteManager: ObservableObject {
@Published var path = NavigationPath()
func jumpToRootView() {
path = NavigationPath()
}
}
I have had to change it to the following code for just a single screen to be displayed.
@State private var pathSports: NavigationPath = NavigationPath()
var body: some View {
NavigationStack(path: $pathSports) {
....
}
} Have others experienced this same problem, or is it just me?
Many thanks.
It is not just you. There are a few threads here talking about this including https://developer.apple.com/forums/thread/759542.
There is the issue you mentioned and another that causes the “back” navigation to display views that were previously in the NavigationPath stack, but shouldn’t be at the time they are displayed. Specifically within tabs.
Developers on that thread mention that the latest beta for 18.1 appears to fix the issue and also provide a couple of workarounds for 18.0.