BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

Project 4 is broken

Forums > watchOS

@roz0n  

I am on Xcode Version 13.4.1 (13F100) and watchOS 8.5 (19T241)

I've recently started working on Project4 of the latest Hacking with watchOS (SwiftUI) and it seems there's a gnarly bug when using NavigationLink within a TabView that is nested inside a NavigationView. The bug is also currently present in the watchOS Github repo project.

When navigating from the initial view to the ResultsView, the latter quickly pops itself from the stack. I've uploaded a video demonstrating the behavior: https://streamable.com/xojrno

Xcode reports a SwiftUI runtime error when building the project: Accessing State's value outside of being installed on a View. This will result in a constant Binding of the initial value and will not update.

Adding NavigationLinks with empty views didn't solve the issue either.

Project4App.swift

@main
struct Project4App: App {
    var body: some Scene {
        WindowGroup {
            NavigationView {
                MainView()
            }
        }
    }
}

MainView.swift

struct MainView: View {
    var body: some View {
        TabView {
            ContentView()
            CurrenciesView()
        }
    }
}

I'm relatively new to SwiftUI (coming from UIKit), so I apologize beforehand if I'm missing anything obvious.

Edit: Here's a Github issue from another developer that reproduces this bug as well. It's safe to say it's a SwiftUI issue in that case.

1      

Save 50% in my Black Friday sale.

SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.