Some features are available directly as Xcode Build Settings while others can be passed as build command line arguments or settings in a Swift Package Manager Package.swift file.
Programatically, it's possible to determine if a feature is available using the #if directive:
#if hasFeature(StrictConcurrency)
#endifSee Proposa SE-0362 for more details.
A compiler flag is available to enable specific features -enable-upcoming-feature FeatureName. In SPM, features can be enabled in Package.swift using the enableUpcomingFeature setting:
.target(
name: "TargetName",
swiftSettings: [
.enableUpcomingFeature("FeatureName")
])A compiler flag is available to enable specific features -enable-experimental-feature FeatureName. In SPM, features can be enabled in Package.swift using the enableExperimentalFeature setting:
.target(
name: "TargetName",
swiftSettings: [
.enableExperimentalFeature("FeatureName")
])