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.54k stars 1.45k forks source link

NavigationStack(path:root:destination) Not Working #2753

Closed jondlew closed 9 months ago

jondlew commented 9 months ago

Description

NavigationStack(path:root:destination) has stopped working on iOS 16.

Navigation using this method still works under observation-beta, but has stopped working on main.

I've linked to a sample project exhibiting the issue. Additionally, the behavior on iOS 17 seems strange, as the state.path doesn't seem to be popped when using the back navigation button.

Checklist

Expected behavior

Tap on a list item to navigate to detail

Actual behavior

No navigation occurs on iOS 16.

On iOS 17, navigation works, but the navigation path is not popped when using the back button or swipe to go back. Tapping on multiple list items causes the stack to grow, and you have to navigate back multiple times to reach the list view.

Steps to reproduce

Here is a project that exhibits the issue: NavigationStackTester

The Composable Architecture version information

main

Destination operating system

iOS 16 and iOS 17

Xcode version information

15.2

Swift Compiler version information

No response

mbrandonw commented 9 months ago

Hi @jondlew, I'm not sure I understand the issue. NavigationStack is only available on iOS 16+, so how are you running it on iOS 14/15? Even the project you provided is limited to iOS 16.1+.

jondlew commented 9 months ago

Sorry -- brainfart. Replace all iOS 14/15 with iOS 16/17!

So NavigationStack is working on iOS 17, but stopped working on iOS 16.

Clearly still living in the past -- thanks!

mbrandonw commented 9 months ago

It looks like you forgot to use forEach in the parent reducer:

public var body: some ReducerOf<Self> {
  Reduce { state, action in
    // ...
  }
  .forEach(\.path, action: \.path) {
    Path()
  }
}

That should fix things. Since this isn't a problem with the library I am going to convert it to a discussion.