Swift Concurrency in Xcode 26

Hi,

I am confused about Tasks in Xcode 26 (swift 6.2)

When I run the following code and add some breakpoints to view the thread the tasks run on, I see tasks not under a specific thread. (see screenshot)

Questions

  1. Does this mean that task is not associated with any specific thread?
  2. Is this behavior (of Task not associated with any thread) new to Swift 6.2 / Xcode 26 or has it always been the case since introduction of swift concurrency?
  3. Is the following statement from Google search AI overview correct?
  4. Is this behavior documented (in swift.org / developer.apple.com) or mentioned anywhere in WWDC?

In Xcode 26, when working with Swift concurrency, tasks are managed by a cooperative thread pool, not directly tied to specific threads. This means tasks are executed concurrently, potentially switching between threads as needed, but the system handles the thread management for you. Xcode 26 also introduces improvements for debugging Swift concurrency, allowing stepping through asynchronous functions and displaying task IDs.

  1. Or am I missing something?

Build Settings / Configuration

  • Approachable Concurrency: Yes
  • Default Actor Isolation: Main Actor
  • Strict Concurrency: Complete
  • Toolchain: Swift 6.2 development snapshot 2025-06-14 (a)

Code

import Foundation

@concurrent
func printNumbers() async {
    for index in 1...100 {
        print(index)
    }
}


Task {
    async let _ = await printNumbers()
    async let _ = await printNumbers()
    async let _ = await printNumbers()
    async let _ = await printNumbers()
}

RunLoop.main.run()

Screenshot

This was always the case; A task is not associated with a specific thread. The one exception to that is tasks running on the main actor, but that's because the main actor's executor is special and uses only the main thread.

So in other words: tasks run on some specific executor, if running on an actor, that'll mean running on that actor's executor. The mainactor's executor is special and tied to a specific thread, generally though, tasks are not bound to a specific thread.

You could write your own executor which would use some other specific thread if you wanted to.

Probably we mention it in many more talks, but that's a good one to check about this topic: Swift concurrency: Behind the scenes - WWDC21 - Videos - Apple Developer

4 Likes

@ktoso thank you so much for clearing that.

Very clear explanation!

I just tried it on Xcode 16.4 and you were right (using 16.4 toolchain), it was the same

1 Like

Glad this helped then.

While I'm here I'll drop another link, about embracing structured concurrency from wwdc-2023: Beyond the basics of structured concurrency - WWDC23 - Videos - Apple Developer and this year's: Code-along which you may find helpful in understanding threading details and how to use concurrency in practice: Code-along: Elevate an app with Swift concurrency - WWDC25 - Videos - Apple Developer :slight_smile:

3 Likes

@ktoso Thanks a lot, those videos were very very helpful!!

1 Like