Hello guys,
I am following along the CodeHistory app and on one of the last stages they ask to set a background modifier at the end of a ZStack to include a NavigationLink to the GameOver view.
Unfortunately the NavigationLink used is now deprecated on iOS 16 devices and this makes the project to not compile.
See below pictures:
Any idea on how to get around this?
5 Likes
I’m having a similar issue while building the the store app in the Navigation section of the course. Any recommendations?

Same issue here!
The course is outdated 
Solved it like this:
//
// ContentView.swift
// Ligaya Store
//
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
VStack {
Text("Items in stock")
.font(.title)
.padding()
Spacer()
NavigationLink("Shrimp Chips") { ItemDetailView(itemName: "Shrimp Chips") }
Spacer()
}
.padding()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
//
// ItemDetailView.swift
// Ligaya Store
//
import SwiftUI
struct ItemDetailView: View {
@State var quantityRemaining = Int.random(in: 1...5)
@State var isCartEmpty = false
let itemName: String
var body: some View {
NavigationStack {
VStack {
Text("\(itemName)")
.font(.title)
.padding()
Spacer()
Image(systemName: "photo")
.font(.system(size: 200))
.padding()
Text("Quantity Remaining: \(quantityRemaining)")
Spacer()
Button {
if quantityRemaining > 0 {
quantityRemaining -= 1
if quantityRemaining == 0 {
isCartEmpty = true
}
}
print("Remaining quantity: \(quantityRemaining)")
} label: {
Text("Add one to your cart")
}
Spacer()
}
.navigationDestination(isPresented: $isCartEmpty) {
Text("You bought all the \(itemName)!")
}
} }
}
struct ItemDetailView_Previews: PreviewProvider {
static var previews: some View {
ItemDetailView(itemName: "Test Item")
}
}
I still don’t get why I get no animation between the cart and the empty cart text.
Update the course 
2 Likes
You’re getting this because iOS 16 switched to using NavigationStack instead of NavigationView. To fix this simply change your minimum deployment target to iOS 15 or 14.
If you click on your main project folder in the navigator panel this will open up the project settings. Under general, you’ll see a “Minimum Deployments” section. You can set this to 15 or 14 or anything lower than targeting only those iOS versions that are running 16+. This is normal as most apps support devices that are running older versions anyways because they don’t want to exclude users on older OS’s.
I hope this helps.
Same here, fixed by changing the minimum deployment targets. Hopefully they can update the course to avoid confusion.
Thanks! It helped me to unstuck!