Replies: 2 comments 3 replies
-
|
Hi @jcmourey, I am guessing you are using default main actor isolation and Swift 5 language mode (the defaults for new Xcode 26 projects)? Technically right now your code is invalid from a concurrency stand point, but the errors/warnings are being hidden from you because of Swift 5 mode. The print outs you are seeing are just the effect of undefined behavior due to using the concurrency tools incorrectly (sometimes Swift will just crash too). You can either turn those errors/warnings on (either Swift 6 language mode or complete concurrency checking) to fix the problems, and then you will see that that the print outs are correct. Or you can turn off default main actor isolation to get the correct print outs. And the problem you are seeing here is the same thing happening in this discussion #404, and is one of the many reasons why we recommend not using the default settings for new projects in Xcode 26. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, @mbrandonw. Adding back the Sendable conformances allows this code to build in Swift 6 with default main actor isolation turned off. And the code works correctly. However, keeping that same new code, when I go back to Swift 5 mode with default main actor isolation, I'm still getting the same incorrect behavior. I'm not using that mode anymore, but am I missing something? Seems like it should work in either mode, no? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
From slack:
I am completely mystified by this. I created the smallest possible app to exhibit the issue.
It's only broken when using async functions AND the @DependencyClient macro.
Ilia found this gets fixed by using Swift 6 language mode.
Beta Was this translation helpful? Give feedback.
All reactions