So I've been researching about Swift 6 and concurrency support.
3 pieces of documentation I found seems confusing when put together:
1. Suggestion to add StrictConcurrency
explicitly
When using Swift 6.0 tools or later, use
SwiftSetting.enableUpcomingFeature
in the Swift settings for the given target:.target( name: "MyTarget", swiftSettings: [ .enableUpcomingFeature("StrictConcurrency") ] )
From swift.org: https://www.swift.org/documentation/concurrency/#in-a-swiftpm-package-manifest
2. Indication that swift-tools-version 6.0 enables Swift 6 language mode
Package manifest
A
Package.swift
file that usesswift-tools-version
of6.0
will enable the Swift 6 language mode for all targets
From swift.org: https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/swift6mode/#Package-manifest
3. Explanation that Swift 6 language mode guarantees StrictConcurrency
With the Swift 6 language mode, the compiler can now guarantee that concurrent programs are free of data races. When enabled, compiler safety checks that were previously optional become required.
From swift.org: https://www.swift.org/migration/documentation/migrationguide/
Conclusion and confusion
My conclusion is that adding `` will enable "Swift 6 language mode" for all targets, which in turn enables StrictConcurrency by default...
If that is the case, why would we ever manually pass the StrictConcurrency
flag like so:
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency")
]
to a target when using swift-tools-version: 6.0
...?
Isn't this the default?