Skip to content

Commit 8f33cac

Browse files
Bump minimum Swift version to 6.0 (#216)
## Motivation Now that Swift 6.2 has been released, we should drop support for 5.10, in line with our three version support window. ## Modifications - Bump minimum tools version in package manifest - Update README with minimum Swift version for each version range - Remove compiler settings in package manifest that are subsumed by Swift 6 language mode - Add `public typealias _NIOSSHSendableMetatype`, which resolves to `Swift.SendableMetatype` for Swift >= 6.2, and `Any` on < 6.2 - Have public protocols refine `SendableMetatype` on Swift >= 6.2, using `_NIOSSHSendableMetatype` ## Result Package now requires Swift >= 6.0. --------- Co-authored-by: Cory Benfield <[email protected]>
1 parent a6e046e commit 8f33cac

File tree

9 files changed

+47
-35
lines changed

9 files changed

+47
-35
lines changed

.github/workflows/pull_request.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ jobs:
1717
name: Unit tests
1818
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
1919
with:
20-
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
21-
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors"
22-
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors"
23-
linux_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors"
24-
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
25-
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
20+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors"
21+
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors"
22+
linux_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors"
23+
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
24+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
2625

2726
benchmarks:
2827
name: Benchmarks

Benchmarks/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.10
1+
// swift-tools-version:6.0
22

33
import PackageDescription
44

Package.swift

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.10
1+
// swift-tools-version:6.0
22
//===----------------------------------------------------------------------===//
33
//
44
// This source file is part of the SwiftNIO open source project
@@ -17,21 +17,13 @@ import PackageDescription
1717

1818
let strictConcurrencyDevelopment = false
1919

20-
let strictConcurrencySettings: [SwiftSetting] = {
21-
var initialSettings: [SwiftSetting] = []
22-
initialSettings.append(contentsOf: [
23-
.enableUpcomingFeature("StrictConcurrency"),
24-
.enableUpcomingFeature("InferSendableFromCaptures"),
25-
])
20+
var swiftSettings: [SwiftSetting] = []
2621

27-
if strictConcurrencyDevelopment {
28-
// -warnings-as-errors here is a workaround so that IDE-based development can
29-
// get tripped up on -require-explicit-sendable.
30-
initialSettings.append(.unsafeFlags(["-Xfrontend", "-require-explicit-sendable", "-warnings-as-errors"]))
31-
}
32-
33-
return initialSettings
34-
}()
22+
if strictConcurrencyDevelopment {
23+
// -warnings-as-errors here is a workaround so that IDE-based development can
24+
// get tripped up on -require-explicit-sendable.
25+
swiftSettings.append(.unsafeFlags(["-Xfrontend", "-require-explicit-sendable", "-warnings-as-errors"]))
26+
}
3527

3628
let package = Package(
3729
name: "swift-nio-ssh",
@@ -59,7 +51,7 @@ let package = Package(
5951
.product(name: "Crypto", package: "swift-crypto"),
6052
.product(name: "Atomics", package: "swift-atomics"),
6153
],
62-
swiftSettings: strictConcurrencySettings
54+
swiftSettings: swiftSettings
6355
),
6456
.executableTarget(
6557
name: "NIOSSHClient",
@@ -69,7 +61,7 @@ let package = Package(
6961
.product(name: "NIOPosix", package: "swift-nio"),
7062
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
7163
],
72-
swiftSettings: strictConcurrencySettings
64+
swiftSettings: swiftSettings
7365
),
7466
.executableTarget(
7567
name: "NIOSSHServer",
@@ -80,7 +72,7 @@ let package = Package(
8072
.product(name: "NIOFoundationCompat", package: "swift-nio"),
8173
.product(name: "Crypto", package: "swift-crypto"),
8274
],
83-
swiftSettings: strictConcurrencySettings
75+
swiftSettings: swiftSettings
8476
),
8577
.executableTarget(
8678
name: "NIOSSHPerformanceTester",
@@ -90,7 +82,7 @@ let package = Package(
9082
.product(name: "NIOEmbedded", package: "swift-nio"),
9183
.product(name: "Crypto", package: "swift-crypto"),
9284
],
93-
swiftSettings: strictConcurrencySettings
85+
swiftSettings: swiftSettings
9486
),
9587
.testTarget(
9688
name: "NIOSSHTests",
@@ -100,7 +92,7 @@ let package = Package(
10092
.product(name: "NIOEmbedded", package: "swift-nio"),
10193
.product(name: "NIOFoundationCompat", package: "swift-nio"),
10294
],
103-
swiftSettings: strictConcurrencySettings
95+
swiftSettings: swiftSettings
10496
),
10597
]
10698
)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ SwiftNIO SSH | Minimum Swift Version
2121
`0.6.2 ..< 0.9.0` | 5.6
2222
`0.9.0 ..< 0.9.2` | 5.8
2323
`0.9.2 ..< 0.10.0` | 5.9
24-
`0.10.0 ...` | 5.10
24+
`0.10.0 ... 0.12.0` | 5.10
25+
`0.12.0 ...` | 6.0
2526

2627
## What does SwiftNIO SSH support?
2728

Sources/NIOSSH/Connection State Machine/Operations/AcceptsUserAuthMessages.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import NIOCore
1616

17-
protocol AcceptsUserAuthMessages {
17+
protocol AcceptsUserAuthMessages: _NIOSSHSendableMetatype {
1818
var userAuthStateMachine: UserAuthenticationStateMachine { get set }
1919

2020
var role: SSHConnectionRole { get }

Sources/NIOSSH/Constants.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
public enum Constants: Sendable {
1616
static let version = "SSH-2.0-SwiftNIOSSH_1.0"
1717

18-
public static let bundledTransportProtectionSchemes: [NIOSSHTransportProtection.Type] = [
19-
AES256GCMOpenSSHTransportProtection.self, AES128GCMOpenSSHTransportProtection.self,
20-
]
18+
public static let bundledTransportProtectionSchemes: [(NIOSSHTransportProtection & _NIOSSHSendableMetatype).Type] =
19+
[
20+
AES256GCMOpenSSHTransportProtection.self, AES128GCMOpenSSHTransportProtection.self,
21+
]
2122
}

Sources/NIOSSH/Key Exchange/EllipticCurveKeyExchange.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Foundation
2424

2525
/// This protocol defines a container used by the key exchange state machine to manage key exchange.
2626
/// This type erases the specific key exchanger.
27-
protocol EllipticCurveKeyExchangeProtocol {
27+
protocol EllipticCurveKeyExchangeProtocol: _NIOSSHSendableMetatype {
2828
init(ourRole: SSHConnectionRole, previousSessionIdentifier: ByteBuffer?)
2929

3030
func initiateKeyExchangeClientSide(allocator: ByteBufferAllocator) -> SSHMessage.KeyExchangeECDHInitMessage

Sources/NIOSSH/TransportProtection/AESGCM.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ extension AESGCMTransportProtection: NIOSSHTransportProtection {
162162
/// algorithm, and instead by ignoring the result of the MAC negotiation.
163163
///
164164
/// This algorithm does not encrypt the length field, instead encoding it as associated data.
165-
final class AES128GCMOpenSSHTransportProtection: AESGCMTransportProtection {
165+
final class AES128GCMOpenSSHTransportProtection: AESGCMTransportProtection, _NIOSSHSendableMetatype {
166166
override static var cipherName: String {
167167
168168
}
@@ -182,7 +182,7 @@ final class AES128GCMOpenSSHTransportProtection: AESGCMTransportProtection {
182182
/// algorithm, and instead by ignoring the result of the MAC negotiation.
183183
///
184184
/// This algorithm does not encrypt the length field, instead encoding it as associated data.
185-
final class AES256GCMOpenSSHTransportProtection: AESGCMTransportProtection {
185+
final class AES256GCMOpenSSHTransportProtection: AESGCMTransportProtection, _NIOSSHSendableMetatype {
186186
override static var cipherName: String {
187187
188188
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the SwiftNIO open source project
4+
//
5+
// Copyright (c) 2019-2020 Apple Inc. and the SwiftNIO project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
#if compiler(>=6.2)
16+
public typealias _NIOSSHSendableMetatype = SendableMetatype
17+
#else
18+
public typealias _NIOSSHSendableMetatype = Any
19+
#endif

0 commit comments

Comments
 (0)