Skip to content

Commit 98fd41e

Browse files
Explain how to opt-out with Swift 6 tools (#52)
* Explain how to opt-out with Swift 6 tools * Simplify instructions
1 parent 758e99b commit 98fd41e

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

Guide.docc/Swift6Mode.md

+24-22
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,34 @@ invocation using the `-Xswiftc` flag:
2525

2626
### Package manifest
2727

28-
To change the language mode for package as a whole:
28+
A `Package.swift` file that uses `swift-tools-version` of `6.0` will enable
29+
the Swift 6 language mode for all targets.
30+
You can still set the language mode for the package as a whole using the
31+
`swiftLanguageVersions` property of `Package`.
32+
However, you can now also change the language mode as needed on a
33+
per-target basis using the new `swiftLanguageVersion` build setting:
2934

3035
```swift
31-
// swift-tools-version:6.0
32-
// The swift-tools-version declares the minimum version of Swift required to build this package.
36+
// swift-tools-version: 6.0
3337

3438
let package = Package(
35-
name: "MyPackage",
36-
products: [
37-
// ...
38-
],
39-
targets: [
40-
// ...
41-
],
42-
swiftLanguageVersions: [.v6]
43-
)
44-
```
45-
46-
To change the language mode on a per-target basis:
47-
48-
```swift
49-
.target(
50-
name: "MyTarget",
51-
swiftSettings: [
52-
.swiftLanguageVersion(.v6)
53-
]
39+
name: "MyPackage",
40+
products: [
41+
// ...
42+
],
43+
targets: [
44+
// Uses the default tools language mode
45+
.target(
46+
name: "FullyMigrated",
47+
),
48+
// Still requires 5
49+
.target(
50+
name: "NotQuiteReadyYet",
51+
swiftSettings: [
52+
.swiftLanguageVersion(.v5)
53+
]
54+
)
55+
]
5456
)
5557
```
5658

Package.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ let package = Package(
3939
name: "Swift6Examples",
4040
dependencies: ["Library"]
4141
)
42-
],
43-
swiftLanguageVersions: [.v6]
42+
]
4443
)

0 commit comments

Comments
 (0)