How do I make best use of Approachable concurrency?

Asked on 06/18/2025

1 search

To make the best use of Approachable Concurrency in Swift, you can follow these guidelines based on the sessions from WWDC:

  1. Enable Approachable Concurrency Settings: In Xcode, you can enable the Approachable Concurrency setting under the Swift Compiler Concurrency section of the build settings. This setting introduces features that make concurrency easier to work with, such as default actor isolation to the main actor for UI-related code. This helps in writing single-threaded apps that can easily transition to concurrent code when needed. (Embracing Swift concurrency)

  2. Start with Single-Threaded Code: Begin by running your code on the main thread, especially for UI-related tasks. This approach simplifies the initial development and helps maintain data safety. As your app grows, you can introduce concurrency to handle more complex tasks. (Embracing Swift concurrency)

  3. Use Asynchronous Tasks: Introduce asynchronous tasks to handle high-latency operations like network requests. This allows your app to remain responsive while waiting for data. (Embracing Swift concurrency)

  4. Offload Work to Background Threads: For tasks that are computationally expensive or take a long time, move them to background threads. This can be done using Swift's concurrency model, which includes tools like actors and tasks. (Embracing Swift concurrency)

  5. Adopt Structured Concurrency: Use structured concurrency to manage and control your concurrent code. This includes using task groups for more control over parallel tasks. (Code-along: Elevate an app with Swift concurrency)

  6. Profile and Optimize: Use profiling tools to identify performance bottlenecks and determine which parts of your code can benefit from concurrency. This helps in making informed decisions about where to introduce concurrency. (Optimize CPU performance with Instruments)

By following these steps, you can effectively introduce and manage concurrency in your Swift applications, improving performance and responsiveness while maintaining code safety and simplicity.

Embracing Swift concurrency

Embracing Swift concurrency

Join us to learn the core Swift concurrency concepts. Concurrency helps you improve app responsiveness and performance, and Swift is designed to make asynchronous and concurrent code easier to write correctly. We’ll cover the steps you need to take an app through from single-threaded to concurrent. We’ll also help you determine how and when to make the best use of Swift concurrency features – whether it’s making your code more asynchronous, moving it to the background, or sharing data across concurrent tasks.

What’s new in Swift

What’s new in Swift

Join us for an update on Swift. We’ll talk about workflow improvements that make you more productive, and new and modernized library APIs for fundamental programming tasks. We’ll show examples of Swift adoption throughout more layers of the software stack. Finally, we’ll explore new language features for both improving approachability of concurrency, and achieving peak performance when you need it.

Code-along: Elevate an app with Swift concurrency

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.

How do I make best use of Approachable concurrency? | Ask WWDC