2

All my navigation links suddenly stopped working correctly on my app's companion watch app. I first suspected some issue with my model refreshing causing the NavigationLink to be re-created or such. However, it turned out that even the most simple example is broken.

import SwiftUI

@main
struct cls2_navlinkpushbackApp: App {
    var body: some Scene {
        WindowGroup {
            NavigationView {
                ContentView()
            }
        }
    }
}

struct ContentView: View {
    @State private var view: Int = 2
    
    var body: some View {
        Group {
            TabView(selection: $view) {
                TestView()
            }
        }
    }
}

struct TestView: View {
    var body: some View {
        VStack {
            Text("Click on the navlink below.")
            NavigationLink(destination: LinkView()) {
                Text("2) Click me!")
            }
        }
        .navigationTitle(Text("TestView"))
    }
}

struct LinkView: View {
    var body: some View {
        Text("I will pop back immediately :(")
            .navigationTitle(Text("LinkView"))
    }
}

Whenever a NavigationLink is clicked, the destination target is opened and immediately closed. Can anybody confirm this behaviour? I contacted Apple already through a CLS incident but got the advice to create a feedback request instead (which I'm about todo asap, the ID will be placed here then). However, I wonder why nobody else reported the issue so far if this is indeed a bug.

3
  • 2
    For what its worth even the Creating a watchOS App project's navigation seems to be broken (in the simulator). Dec 31, 2021 at 21:12
  • 1
    This stopped working with the release of WatchOS 8.1 I filed feedback then but have not had any response.
    – CodeChimp
    Jan 10 at 15:33
  • Hi I saw the same issue, have you figured it out? Jun 15 at 14:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.