Skip to content

Conversation

@doulos76
Copy link

💡 Pull Request Description

Summary

This PR fixes a Swift 6 concurrency issue in the Todos reducer, where
CancelID inherited the @MainActor isolation from the @Reducer type,
causing a compiler error when used as a Sendable Hashable ID in .cancellable.

Changes

  • Declared CancelID as nonisolated to remove actor isolation.
  • Added explicit Sendable conformance to CancelID.

Result

✅ Eliminates the compiler error:

"Main actor-isolated conformance of 'Todos.CancelID' to 'Hashable' cannot satisfy conformance requirement for a 'Sendable' type parameter."

✅ Keeps Todos reducer stable and compatible with Swift 6’s stricter actor isolation rules.

@mbrandonw
Copy link
Member

Hi @doulos76, the Todos case study compiles just fine for me as-is, and the @Reducer macro does not impose any main actor isolation. How exactly are you getting this error?

@doulos76
Copy link
Author

@mbrandonw
Hello,
Thank you for reviewing the PR.

I’m currently using Xcode 26.0.1, and when I created a new project identical to the one in this repository and tried to build it, I encountered the following issue:

/Users/user/Documents/GitHub/my-ios-app-study/Architecture/TCA/Todos/Todos/Todos.swift:108:12 
Main actor-isolated conformance of 'Todos.CancelID' to 'Hashable' cannot satisfy conformance requirement for a 'Sendable' type parameter

As you mentioned, the example in the repository builds without any issues.

@mbrandonw
Copy link
Member

Hi @doulos76, this is because projects created in Xcode 26 use default main actor isolation, and the demos in TCA do not. If you want to use that mode of Swift then you may find you need to adapt things slightly.

We may someday decide to update our demos to use default main actor isolation, but we have so far found it's more trouble than its worth with many bugs and limitations. I'm going to close this for now, but if you have more questions feel free to open a discussion.

@mbrandonw mbrandonw closed this Nov 11, 2025
@doulos76
Copy link
Author

@mbrandonw
Thanks for the detailed explanation — that clears things up! Appreciate the insight about main actor isolation and TCA’s current approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants