Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you fix Xcode 14 warning: NavigationLink presenting a value must appear inside a NavigationContent-based NavigationView. Link will be disabled

Since installing Xcode 14, I am now getting the following error message printed in my console:

NavigationLink presenting a value must appear inside a NavigationContent-based NavigationView. Link will be disabled.

My app is structured as follows:

  1. I have View A wrapped in a NavigationView. The Navigation View has a navigation link inside it that links to View B.

  2. I have View B that doesn't have a Navigation View, but has a navigation link to View C. View B inherits the navigation view defined in View A

The warning is printed when I press the back button on View B, popping back to View A. The warning goes away when I wrap View B in a NavigationView, but this of course now displays View B in two Navigation Views, which is not what I want.

I'm unsure why this warning is printing, because View B inherits the NavigationView defined in View A.

like image 320
xanderbuck Avatar asked Dec 04 '25 09:12

xanderbuck


1 Answers

I had the same issue. Adding a check for iOS16 and using the new navigationstack if true fixed it for me.

WindowGroup {
    if #available(iOS 16.0, *) {
        NavigationStack {
            ContentView()
        }
    } else {
        // Fallback on earlier versions
        NavigationView {
            ContentView()
        }
    }
}
like image 63
tomu94 Avatar answered Dec 06 '25 04:12

tomu94



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!