NavigationSplitView Error

When I use NavigationSplitView, it shows that it requires iOS16.0 or newer and comes with an error.

And even I add if #available(iOS 16, *) to clear the error, the perview still doesn't come out.

Then after I swapped to NavigationView which is the old one, it says this will soon become unavailable.

I'm confused which one be used exactly.

Have you checked the minimum deployment for your target? If it is below 16.0, you will receive the error you mentioned about requiring iOS 16.0.

No matter where the deployment target is set to, you will still receive the warning about the deprecation of NavigationView as it is being deprecated in the future, but this will not stop your project from running. (this just means you should be supporting NavigationStack instead of NavigationView wherever you can)

So, if your project has a minimum deployment of iOS 16.0, you should only be using NavigationStack/NavigationSplitView.

If you are creating a project that supports earlier iOS versions, use something in this format so you can use the new API wherever possible:

  if #available(iOS 16.0, *) {
         NavigationSplitView
} 
else {
NavigationView
}
NavigationSplitView Error
 
 
Q