How can I enable “Approachable Concurrency” for a Swift Package?

I’m aware that Xcode version 26 beta 3 provides an option to enable Swift’s Approachable Concurrency feature at the project level. However, I’d like to achieve the same for a Swift Package. Could you please advise on how to enable Approachable Concurrency support specifically for a Swift Package?

Answered by DTS Engineer in 849892022

Xcode’s Approachable Concurrency build setting (SWIFT_APPROACHABLE_CONCURRENCY) enabled a bunch of upcoming feature flags. You can find the current list in the Quick Help for that build setting.

Upcoming feature flags are specifically supported in Swift Package Manager. See SE-0362 Piecemeal adoption of upcoming language improvements for the details.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Xcode’s Approachable Concurrency build setting (SWIFT_APPROACHABLE_CONCURRENCY) enabled a bunch of upcoming feature flags. You can find the current list in the Quick Help for that build setting.

Upcoming feature flags are specifically supported in Swift Package Manager. See SE-0362 Piecemeal adoption of upcoming language improvements for the details.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Oh, and by an amazing coincidence, one of the iOS development blogs I read just published an article about this:

https://useyourloaf.com/blog/approachable-concurrency-in-swift-packages/

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

While I was writing a lesson for my concurrency course, I ran into the same question. While I looked at the mentioned article, it did not list all upcoming features that come with Approachable Concurrency.

Note that this list might change in the future, but as of today, the following features are enabled:

  • Disable Outward Actor Isolation Inference (SE-401)
  • Usability of global-actor-isolated types (SE-434)
  • Global-actor isolated conformances (SE-470)
  • Inferring Sendable for methods and key path literals (SE-418)
  • nonisolated(nonsending) by Default (SE-461)

I went ahead and copied all upcoming feature flags for you. Here's the code to use inside your Swift Package:

.target(
    name: "YourPackageTarget",
    swiftSettings: [
        .enableUpcomingFeature("DisableOutwardActorInference"),
        .enableUpcomingFeature("GlobalActorIsolatedTypesUsability"),
        .enableUpcomingFeature("InferIsolatedConformances"),
        .enableUpcomingFeature("InferSendableFromCaptures"),
        .enableUpcomingFeature("NonisolatedNonsendingByDefault")
    ]
)

Don't forget to update your package tools version:

// swift-tools-version: 6.2

Although you can already start using some of these upcoming features since Swift 5.9 / 6.0.

–––

Antoine van der Lee — Founder of SwiftLee

Teaching Concurrency at swiftconcurrencycourse.com

How can I enable “Approachable Concurrency” for a Swift Package?
 
 
Q