|  | 
| 2 | 2 | layout: page | 
| 3 | 3 | date: 2024-03-03 12:00:00 | 
| 4 | 4 | title: Enabling Complete Concurrency Checking | 
|  | 5 | +redirect_to: https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/enabledataracesafety | 
| 5 | 6 | --- | 
|  | 7 | +<meta http-equiv="refresh" content="0; url=https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/"> | 
|  | 8 | +<link rel="canonical" href="https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/" /> | 
| 6 | 9 | 
 | 
| 7 |  | -Data-race safety in the Swift 6 language mode is designed for incremental migration. You can address data-race safety issues in your projects module-by-module, and you can enable the compiler's actor isolation and `Sendable` checking as warnings in the Swift 5 language mode, allowing you to assess your progress toward eliminating data races before turning on the Swift 6 language mode. | 
| 8 |  | - | 
| 9 |  | -Complete data-race safety checking can be enabled as warnings in the Swift 5 language mode using the `-strict-concurrency` compiler flag. | 
| 10 |  | - | 
| 11 |  | -## Using the Swift compiler | 
| 12 |  | - | 
| 13 |  | -To enable complete concurrency checking when running `swift` or `swiftc` directly at the command line, pass `-strict-concurrency=complete`: | 
| 14 |  | - | 
| 15 |  | -``` | 
| 16 |  | -~ swift -strict-concurrency=complete main.swift | 
| 17 |  | -``` | 
| 18 |  | - | 
| 19 |  | -## Using SwiftPM | 
| 20 |  | - | 
| 21 |  | -### In a SwiftPM command-line invocation | 
| 22 |  | - | 
| 23 |  | -`-strict-concurrency=complete` can be passed in a Swift package manager command-line invocation using the `-Xswiftc` flag: | 
| 24 |  | - | 
| 25 |  | -``` | 
| 26 |  | -~ swift build -Xswiftc -strict-concurrency=complete | 
| 27 |  | -~ swift test -Xswiftc -strict-concurrency=complete | 
| 28 |  | -``` | 
| 29 |  | - | 
| 30 |  | -This can be useful to gauge the amount of concurrency warnings before adding the flag permanently in the package manifest as described in the following section. | 
| 31 |  | - | 
| 32 |  | -### In a SwiftPM package manifest | 
| 33 |  | - | 
| 34 |  | -To enable complete concurrency checking for a target in a Swift package using Swift 5.9 or Swift 5.10 tools, use [`SwiftSetting.enableExperimentalFeature`](https://developer.apple.com/documentation/packagedescription/swiftsetting/enableexperimentalfeature(_:_:)) in the Swift settings for the given target: | 
| 35 |  | - | 
| 36 |  | -```swift | 
| 37 |  | -.target( | 
| 38 |  | -  name: "MyTarget", | 
| 39 |  | -  swiftSettings: [ | 
| 40 |  | -    .enableExperimentalFeature("StrictConcurrency") | 
| 41 |  | -  ] | 
| 42 |  | -) | 
| 43 |  | -``` | 
| 44 |  | - | 
| 45 |  | -When using Swift 6.0 tools or later, use [`SwiftSetting.enableUpcomingFeature`](https://developer.apple.com/documentation/packagedescription/swiftsetting/enableupcomingfeature(_:_:)) in the Swift settings for the given target: | 
| 46 |  | - | 
| 47 |  | -```swift | 
| 48 |  | -.target( | 
| 49 |  | -  name: "MyTarget", | 
| 50 |  | -  swiftSettings: [ | 
| 51 |  | -    .enableUpcomingFeature("StrictConcurrency") | 
| 52 |  | -  ] | 
| 53 |  | -) | 
| 54 |  | -``` | 
| 55 |  | - | 
| 56 |  | -## Using Xcode | 
| 57 |  | - | 
| 58 |  | -To enable complete concurrency checking in an Xcode project, set the "Strict Concurrency Checking" setting to "Complete" in the Xcode build settings. Alternatively, you can set `SWIFT_STRICT_CONCURRENCY` to `complete` in an xcconfig file: | 
| 59 |  | - | 
| 60 |  | -``` | 
| 61 |  | -// In a Settings.xcconfig | 
| 62 |  | -
 | 
| 63 |  | -SWIFT_STRICT_CONCURRENCY = complete; | 
| 64 |  | -``` | 
|  | 10 | +This page should redirect automatically to https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide | 
0 commit comments