Skip to content

"Your first feature" tutorial doesn't compile #3732

@cameronmcefee

Description

@cameronmcefee

Description

In the Your First Feature tutorial (and probably others), the given code doesn't compile due to a lack of satisfying the conformance to Reducer. I don't know if it's written this way intentionally so I didn't make a pull request to update it. However, I was able to get it compile by copying similar (but different) code from the Getting Started guide.

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

The code should compile

Actual behavior

Received the error: Type 'CounterFeature' does not conform to protocol 'Reducer' without further explanation of what doesn't conform, and no "fix it" to add stubs.

Reproducing project

import ComposableArchitecture


@Reducer
struct CounterFeature {
  @ObservableState
  struct State {
    var count = 0
  }
  
  enum Action {
    case decrementButtonTapped
    case incrementButtonTapped
  }
  
-  // Does not compile
-  var body: some ReducerOf<Self> {
+  // Compiles
+  var body: some Reducer<State, Action>
    Reduce { state, action in
      switch action {
      case .decrementButtonTapped:
        state.count -= 1
        return .none
        
      case .incrementButtonTapped:
        state.count += 1
        return .none
      }
    }
  }
}

The Composable Architecture version information

1.20.2

Destination operating system

MacOS 15.5

Xcode version information

Version 26.0 beta 4

Swift Compiler version information

6.2 (whatever the defaults of the project are)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions