pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.35k stars 1.44k forks source link

navigationDestination(isPresented:destination:) #3420

Closed tospery closed 2 weeks ago

tospery commented 2 weeks ago

Description

How to resolve warning in 04-Navigation-Lists-NavigateAndLoad.swift file: struct NavigateAndLoadListView: View { @Bindable var store: StoreOf

var body: some View {
    Form {
        Section {
            AboutView(readMe: readMe)
        }
        ForEach(store.rows) { row in
            NavigationLink(
                "Load optional counter that starts from \(row.count)",
                tag: row.id,
                selection: .init(
                    get: { store.selection?.id },
                    set: { id in store.send(.setNavigation(selection: id)) }
                )
            ) {
                if let store = store.scope(state: \.selection?.value, action: \.counter) {
                    CounterView(store: store)
                } else {
                    ProgressView()
                }
            }
        }
    }
    .navigationTitle("Navigate and load")
}

} the warning is: 'init(_:tag:selection:destination:)' was deprecated in iOS 16.0: use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView

Checklist

Expected behavior

No response

Actual behavior

No response

Reproducing project

No response

The Composable Architecture version information

No response

Destination operating system

No response

Xcode version information

No response

Swift Compiler version information

No response

stephencelis commented 2 weeks ago

That case study is using some older SwiftUI APIs which are deprecated, and are there just as examples for folks still targeting <iOS 16. There are other more modern examples, as well, but we can't show them both off in the same target and avoid the warnings.

Because this isn't a library bug, and so I'm going to convert it to a discussion, but if you have specific questions we can help with, let us know!