SwiftUI crash/bug—Trying to pop to a missing destination

I have a simple main app architecture:

struct ContentView: View {

@State private var isSignedIn = false
@AppStorage("onboardingCompleted") var onboardingCompleted: Bool = false

var body: some View {
    Group {
        if onboardingCompleted && isSignedIn {
            MainView()
        } else {
            OnboardingView()
        }
    }
    .onAppear() {
        signIn()
    }
}

OnboardingView is a NavigationView. MainView is a TabView. I switch between these when the user finishes onboarding. However, as the user taps on the finish button in the last onboarding step, this gets written to the console: Trying to pop to a missing destination - SwiftUI/NavigationBridge_PhoneTV.swift:213 - please file a bug report.

In production, this causes a crash. I looked around and it seems it is an issue when you embed TabView inside NavigationView or vice versa? But here it's not the case, they are standalone and I switch between them.

Any thoughts?

Replies

Hi @vojta.bohm ,

I tried to recreate your problem in a simple test app that switched between a NavigationView and a TabView and had no problems.

First, if you're targeting iOS 16 and later, please use NavigationStack

Can you please tell me what iOS you're running this on? It seems like there's something else causing this issue here. I recommend trying to reproduce this by slowly removing functionality that could be creating this behavior and until the error no longer shows. You can also try starting with a clean project and slowly adding the same behaviors as your app until you get the error again. Feel free to come back here with any questions or more code and I can try to help further.

Lastly, to reference this:

it seems it is an issue when you embed TabView inside NavigationView or vice versa? But here it's not the case, they are standalone and I switch between them

You should not put a TabView inside a NavigationView or NavigationStack, but you can put a NavigationStack inside of each tab of a TabView .