"Your first feature" tutorial doesn't compile #3733
-
DescriptionIn 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
Expected behaviorThe code should compile Actual behaviorReceived the error: Reproducing projectimport 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 information1.20.2 Destination operating systemMacOS 15.5 Xcode version informationVersion 26.0 beta 4 Swift Compiler version information6.2 (whatever the defaults of the project are) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
@cameronmcefee That code compiles just fine for me in Xcode 16.4: ![]() Can you please provide more information on how to reproduce, ideally with a project that shows the issue, as well as more of a description of what goes wrong. |
Beta Was this translation helpful? Give feedback.
-
Sorry about that @stephencelis. This was in a brand new project so my brain just omitted the "I should add repro" step 🤦 . I updated the OP but it's 26 Beta 4. The compiler message provides no further info, unfortunately. I tried looking at the definitions but it wasn't obvious to me what was wrong. ![]() |
Beta Was this translation helpful? Give feedback.
-
@cameronmcefee Xcode 26 uses main actor isolation by default, which means you need to explicitly make everything There are pending changes to the language that will give us the ability to signal this to the compiler, but they haven't shipped as of beta 4. Since this isn't a bug with the library I'm going to convert to a discussion. |
Beta Was this translation helpful? Give feedback.
-
Ah, that makes sense, thanks for clarifying. It's a shame the warnings didn't make that more clear as they've done in other cases where I've seen that conflict. |
Beta Was this translation helpful? Give feedback.
@cameronmcefee Xcode 26 uses main actor isolation by default, which means you need to explicitly make everything
nonisolated
or switch back to nonisolated as the default.There are pending changes to the language that will give us the ability to signal this to the compiler, but they haven't shipped as of beta 4.
Since this isn't a bug with the library I'm going to convert to a discussion.