pointfreeco/swift-composable-architecture

NavigationStack(path:root:destination) Not Working

jondlew opened this issue · 3 comments

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

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

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

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+.

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!

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.