r/swift • u/romit5587 • 4h ago
Moving an existing app to Swift 6 strict concurrency: the order I'd do it in
After nine years of iOS work, the concurrency migration is the one where order matters most. Turning on Swift 6 mode in one go usually produces hundreds of errors and no idea where to start. This is the sequence that keeps it manageable:
- Stay in Swift 5 mode and set strict concurrency checking to "complete" first. You get the same diagnostics as warnings, so the app keeps building while you work through them.
- Start at the leaves. Models and small utility types are usually easiest to make Sendable. Value types with Sendable properties mostly just work. Fixing these first removes a lot of noise further up.
- Decide what really belongs on the main actor. View models and anything touching UI can usually be @MainActor as a whole type. That's simpler and safer than marking individual methods.
- Treat @unchecked Sendable and nonisolated(unsafe) as debt. They're fine to unblock a module, but leave a comment explaining why each one is safe, or they quietly become permanent.
- Use @preconcurrency on imports of modules you don't control, instead of fighting their missing annotations.
- Migrate module by module (or target by target) and switch each to Swift 6 mode once its warnings are gone. Smaller PRs are much easier to review.
- Watch for behaviour changes, not just compile errors. Moving work onto or off the main actor can change ordering, so test the flows that depend on timing.
What has been the hardest part of the migration for you?