Why did Apple create the @background annotation? Wasn’t a nonisolated async method already global?
Asked on 2025-07-21
1 search
Apple introduced the @background
annotation to provide a more explicit way to manage concurrency in Swift, particularly when dealing with tasks that should run on a background thread. While nonisolated async methods are indeed global in the sense that they are not tied to a specific actor, the @background
annotation offers a clear and explicit way to indicate that a method should always run on a background thread. This helps in maintaining code clarity and ensuring that tasks are offloaded to the background, which is crucial for keeping apps responsive, especially when performing CPU-intensive tasks.
In the session Migrate your app to Swift 6, it is discussed how Swift concurrency makes guarantees explicit, and how annotations like @background
can help in managing these guarantees effectively. This approach is part of Swift's broader strategy to make concurrent code safer and more predictable by providing clear isolation guarantees and reducing the risk of data races.

Migrate your app to Swift 6
Experience Swift 6 migration in action as we update an existing sample app. Learn how to migrate incrementally, module by module, and how the compiler helps you identify code that’s at risk of data races. Discover different techniques for ensuring clear isolation boundaries and eliminating concurrent access to shared mutable state.

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Code-along: Elevate an app with Swift concurrency
Learn how to optimize your app’s user experience with Swift concurrency as we update an existing sample app. We’ll start with a main-actor app, then gradually introduce asynchronous code as we need to. We’ll use tasks to optimize code running on the main actor, and discover how to parallelize code by offloading work to the background. We’ll explore what data-race safety provides, and work through interpreting and fixing data-race safety errors. Finally, we’ll show how you can make the most out of structured concurrency in the context of an app.