Swift Concurrency in 2026: Async Patterns That Actually Ship

Swift concurrency in 2026 means structured concurrency by default. Use async let for a fixed number of concurrent calls, task groups when the count is dynamic, and avoid scattering Task { } everywhere. That keeps cancellation, priority, and error propagation working the way they should.
Part of the complete app development guide.
On this page
- Structured concurrency is the default, not a nice-to-have
- Task groups when you do not know the count
- Actors: use them for state, not for everything
- Actor reentrancy will bite you
- Sendable and strict concurrency checking
- Where this touches the web side
- AsyncSequence for streaming data
- Common mistakes I still see
- FAQ
- Do I need Swift 6 mode to use these patterns?
- Is async/await always faster than GCD?
- When should I use an actor instead of a lock?
Swift concurrency has been stable long enough that the old advice is starting to age badly. Most of the async code I see in production still carries habits from the GCD era, and those habits cause the bugs people blame on “Swift concurrency being hard.” Here is what actually works now, with code.
Structured concurrency is the default, not a nice-to-have
The single biggest shift since async/await landed is that unstructured tasks are the exception. If you are spawning Task { } everywhere and hoping for the best, you lose cancellation, you lose priority propagation, and you leak work when a view goes away. Structured concurrency gives you a parent-child relationship that cancels cleanly.
func loadDashboard() async throws -> Dashboard {
async let profile = api.fetchProfile()
async let feed = api.fetchFeed()
async let notifications = api.fetchNotifications()
// All three run concurrently. If any throws, the others cancel.
return try await Dashboard(
profile: profile,
feed: feed,
notifications: notifications
)
}
That async let block is the pattern I reach for most. It is concurrent, it is cancellable, and it does not need a task group when the number of children is fixed. When the count is dynamic, use a task group instead.
Task groups when you do not know the count
func loadThumbnails(for ids: [PhotoID]) async throws -> [PhotoID: UIImage] {
try await withThrowingTaskGroup(of: (PhotoID, UIImage).self) { group in
for id in ids {
group.addTask { (id, try await imageLoader.load(id)) }
}
var results: [PhotoID: UIImage] = [:]
for try await (id, image) in group {
results[id] = image
}
return results
}
}
Notice the results come back in completion order, not input order. If order matters, collect into an array and sort afterward. This trips people up constantly.
Actors: use them for state, not for everything
Actors serialize access to their mutable state, which solves a whole class of data races. But wrapping your entire networking layer in an actor is usually wrong. Actors are for state that multiple tasks touch at once, like a cache or a connection pool.
actor ImageCache {
private var storage: [URL: UIImage] = [:]
private var inFlight: [URL: Task] = [:]
func image(for url: URL) async throws -> UIImage {
if let cached = storage[url] { return cached }
if let existing = inFlight[url] { return try await existing.value }
let task = Task { try await download(url) }
inFlight[url] = task
defer { inFlight[url] = nil }
let image = try await task.value
storage[url] = image
return image
}
}
The inFlight dictionary is the part most people miss. Without it, ten views asking for the same image fire ten downloads. The actor guarantees only one task per URL gets created.
Actor reentrancy will bite you
An actor does not hold its lock across an await. That means another call can run while you are suspended. If you check a condition, await, then act on it, the world may have changed. Re-check after every await, or keep the critical section free of suspension points.
Sendable and strict concurrency checking
Swift 6 language mode makes data race safety a compile-time error, not a warning. If you have not migrated yet, do it module by module. The compiler is telling you about real bugs, even when the fix feels annoying.
- Mark value types
Sendablefreely. Structs of Sendable properties are already conformant. - Classes need
finaland immutable stored properties, or you need to isolate them. - Use
@MainActoron view models and UI-touching types. Do not fight it. @unchecked Sendableis a promise you are making to the compiler. Only make it when you have a real lock underneath.
Where this touches the web side
If your app talks to a backend, the async patterns above only help as much as the API allows. Cancellation on the client does nothing if your server holds the connection open for thirty seconds. I have run into this a lot doing Long Island web design work where the iOS client and the API are maintained by the same small team, and the fix is usually on the server: return partial data fast, support range requests, and stop blocking on slow third-party calls.
AsyncSequence for streaming data
For anything that produces values over time (websockets, file reads, sensor data), AsyncSequence is the right abstraction. It composes with the rest of the concurrency system and cancels properly.
for await message in socket.messages {
try Task.checkCancellation()
await handle(message)
}
That checkCancellation() call matters inside long loops. Swift will not throw for you automatically in a plain for await; you have to opt in.
Common mistakes I still see
- Blocking the main actor. Synchronous file or network work in a
@MainActorfunction freezes the UI. Move it off. - Ignoring cancellation. A cancelled task that keeps running is a resource leak with extra steps.
- Overusing Task.detached. It loses priority and task-local values. You almost never want it.
- Assuming actor calls are cheap. They hop executors. Do not call them in tight loops.
FAQ
Do I need Swift 6 mode to use these patterns?
No, but you should be on the path to it. The patterns work in Swift 5.9 and later. Swift 6 mode just turns the data race warnings into errors, which forces you to fix them instead of shipping them.
Is async/await always faster than GCD?
Not necessarily faster, but usually safer. The performance win comes from not blocking threads and from structured cancellation. For pure CPU work, dispatch to a background executor and do not expect async to help.
When should I use an actor instead of a lock?
Use an actor when the protected state is touched from async contexts and you want the compiler to enforce safety. Use a lock when the critical section is tiny, synchronous, and performance-sensitive, since actor hops have overhead.


