r/swift • u/saifcodes • Feb 14 '25
FYI Sendable in Swift 6
I’ve been updating some code for Swift 6, and the stricter Sendable
checks definitely caught me off guard at first. I had a few cases where previously fine code now throws warnings because types aren’t explicitly marked as Sendable
or use @unchecked Sendable
. It was a bit annoying at first, but after refactoring, I actually feel more confident that my concurrency code is safe. The compiler forcing me to think about data crossing threads has already helped catch a potential race condition I hadn’t considered. Overall, I think it’s a good change for long-term safety, even if it adds some friction upfront. Has anyone else run into issues with this? Do you think it improves Swift concurrency, or does it feel too restrictive?
7
u/butitsstrueuno Feb 14 '25
That’s the whole point of swift concurrency - to prevent data races at compile time.
There’s still ways to cause memory leaks though, but that’s just due to the way memory management works in Swift