I am facing an issue in SwiftUI on iOS 18.6.2 where passing a value to a destination view during navigation is not working as expected.
In my implementation, I pass a billerId as a constant (let) to the destination view (BillersItemView) using NavigationLink. This approach works correctly across all previous iOS versions. However, on iOS 18.6.2, the destination view does not receive the updated value properly.
Before triggering navigation, the value is correctly updated in the ViewModel, but the destination view seems to receive an incorrect or stale value, which affects further API calls and UI rendering.
This pattern of passing immutable (let) values is used throughout the app and has always worked reliably, so this behavior appears inconsistent and possibly related to changes in SwiftUI navigation handling in iOS 18.6.2.
Could you please confirm if this is a known issue or if there are any recommended changes or workarounds to ensure correct data passing in this scenario?
It can be very likely a SwiftUI navigation state timing issue that became more visible in iOS 18.x, especially with NavigationLink(isActive:) + external @ObservedObject updates. But i need to know why this is working in others.
I have attached the relevant code for your reference.
import SwiftUI
struct CategoryBillersView: View {
@ObservedObject var billPaymentsVM: BillPaymentsViewModel
@State private var goToBillerItem = false
var body: some View {
NavigationView {
VStack {
NavigationLink(isActive: $goToBillerItem) {
BillersItemView(
billPaymentsVM: billPaymentsVM,
billerId: billPaymentsVM.selectedBillerId
)
} label: {
EmptyView()
}
Button("Go to Biller") {
billPaymentsVM.selectedBillerId = 123
goToBillerItem = true
}
}
}
}
}
struct BillersItemView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel let billerId: Int
var body: some View {
Text("Biller ID: \(billerId)")
.onAppear {
billPaymentsVM.fetchBiller(billerId: billerId)
}
}
}
class BillPaymentsViewModel: ObservableObject { @Published var selectedBillerId: Int = 0 }