Skip to content

Commit 2375537

Browse files
authored
feat: Add Swift 6 language mode support (#920)
1 parent da2b2e9 commit 2375537

File tree

67 files changed

+560
-320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+560
-320
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Swift6 Compatibility
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
env:
10+
AWS_SWIFT_SDK_USE_LOCAL_DEPS: 1
11+
12+
jobs:
13+
bump-swift-tools-version:
14+
if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request'
15+
runs-on: ${{ matrix.runner }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
runner:
20+
- macos-15
21+
xcode:
22+
- Xcode_16.1
23+
destination:
24+
- 'platform=macOS'
25+
steps:
26+
- name: Checkout smithy-swift
27+
uses: actions/checkout@v4
28+
- name: Setup common tools
29+
uses: ./.github/actions/setup-common-tools-composite-action
30+
- name: Build on swift-tools-version 6.0
31+
run: |
32+
perl -pi -e 's{^// swift-tools-version:\d+\.\d+}{// swift-tools-version:6.0}' Package.swift
33+
set -euo pipefail
34+
swift build

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let package = Package(
5656
],
5757
dependencies: {
5858
var dependencies: [Package.Dependency] = [
59-
.package(url: "https://github.com/awslabs/aws-crt-swift.git", exact: "0.48.0"),
59+
.package(url: "https://github.com/awslabs/aws-crt-swift.git", exact: "0.52.1"),
6060
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
6161
]
6262
let isDocCEnabled = ProcessInfo.processInfo.environment["AWS_SWIFT_SDK_ENABLE_DOCC"] != nil
@@ -157,7 +157,10 @@ let package = Package(
157157
),
158158
.target(
159159
name: "SmithyHTTPAPI",
160-
dependencies: ["Smithy"]
160+
dependencies: [
161+
"Smithy",
162+
.product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift")
163+
]
161164
),
162165
.target(
163166
name: "SmithyHTTPClient",

Sources/ClientRuntime/Config/DefaultSDKRuntimeConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public class DefaultAuthSchemeResolverParameters: AuthSchemeResolverParameters {
131131
}
132132
}
133133

134-
public class DefaultAuthSchemeResolver: AuthSchemeResolver {
134+
public final class DefaultAuthSchemeResolver: AuthSchemeResolver, Sendable {
135135
public func resolveAuthScheme(params: AuthSchemeResolverParameters) throws -> [AuthOption] {
136136
return []
137137
}

Sources/ClientRuntime/Config/IdempotencyTokenGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6-
public protocol IdempotencyTokenGenerator {
6+
public protocol IdempotencyTokenGenerator: Sendable {
77
func generateToken() -> String
88
}

Sources/ClientRuntime/Endpoints/CRTResolvedEndpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CRTResolvedEndpoint {
3434
}
3535
}
3636

37-
public func getProperties() -> [String: AnyHashable]? {
37+
public func getProperties() -> [String: EndpointProperty]? {
3838
switch crtResolvedEndpoint {
3939
case let .endpoint(_, _, properties):
4040
return properties

Sources/ClientRuntime/Endpoints/DefaultEndpointResolver.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import struct SmithyHTTPAPI.Endpoint
99
import struct SmithyHTTPAPI.Headers
10+
import enum SmithyHTTPAPI.EndpointPropertyValue
1011

1112
public struct DefaultEndpointResolver<Params: EndpointsRequestContextProviding> {
1213

@@ -32,6 +33,6 @@ public struct DefaultEndpointResolver<Params: EndpointsRequestContextProviding>
3233

3334
let headers = crtResolvedEndpoint.getHeaders() ?? [:]
3435
let properties = crtResolvedEndpoint.getProperties() ?? [:]
35-
return try Endpoint(urlString: url, headers: Headers(headers), properties: properties)
36+
return try Endpoint(urlString: url, headers: Headers(headers), endpointProperties: properties)
3637
}
3738
}

Sources/ClientRuntime/Endpoints/EndpointsAuthSchemeResolver.swift

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import enum SmithyHTTPAPI.EndpointPropertyValue
9+
810
/// Supported authentication schemes
911
public enum EndpointsAuthScheme: Equatable {
1012
case sigV4(SigV4Parameters)
@@ -25,7 +27,8 @@ extension EndpointsAuthScheme {
2527
/// Initialize an AuthScheme from a dictionary
2628
/// - Parameter dictionary: Dictionary containing the auth scheme
2729
public init(from dictionary: [String: Any]) throws {
28-
guard let name = dictionary["name"] as? String else {
30+
guard let endpointProperty = dictionary["name"] as? SmithyHTTPAPI.EndpointPropertyValue,
31+
case let .string(name) = endpointProperty else {
2932
throw EndpointError.authScheme("Invalid auth scheme")
3033
}
3134
switch name {
@@ -60,9 +63,29 @@ extension EndpointsAuthScheme.SigV4Parameters {
6063
/// Initialize a SigV4AuthScheme from a dictionary
6164
/// - Parameter dictionary: Dictionary containing the auth scheme
6265
init(from dictionary: [String: Any]) throws {
63-
self.signingName = dictionary["signingName"] as? String
64-
self.signingRegion = dictionary["signingRegion"] as? String
65-
self.disableDoubleEncoding = dictionary["disableDoubleEncoding"] as? Bool
66+
// For signingName (expected to be a string)
67+
if let value = dictionary["signingName"] as? EndpointPropertyValue,
68+
case let .string(name) = value {
69+
self.signingName = name
70+
} else {
71+
self.signingName = nil
72+
}
73+
74+
// For signingRegion (expected to be a string)
75+
if let value = dictionary["signingRegion"] as? EndpointPropertyValue,
76+
case let .string(region) = value {
77+
self.signingRegion = region
78+
} else {
79+
self.signingRegion = nil
80+
}
81+
82+
// For disableDoubleEncoding (expected to be a bool)
83+
if let value = dictionary["disableDoubleEncoding"] as? EndpointPropertyValue,
84+
case let .bool(flag) = value {
85+
self.disableDoubleEncoding = flag
86+
} else {
87+
self.disableDoubleEncoding = nil
88+
}
6689
}
6790
}
6891

@@ -86,9 +109,34 @@ extension EndpointsAuthScheme.SigV4AParameters {
86109
/// Initialize a SigV4AAuthScheme from a dictionary
87110
/// - Parameter dictionary: Dictionary containing the auth scheme
88111
init(from dictionary: [String: Any]) throws {
89-
self.signingName = dictionary["signingName"] as? String
90-
self.signingRegionSet = dictionary["signingRegionSet"] as? [String]
91-
self.disableDoubleEncoding = dictionary["disableDoubleEncoding"] as? Bool
112+
// Extract signingName
113+
if let value = dictionary["signingName"] as? EndpointPropertyValue,
114+
case let .string(name) = value {
115+
self.signingName = name
116+
} else {
117+
self.signingName = nil
118+
}
119+
120+
// Extract signingRegionSet as an array of String
121+
if let value = dictionary["signingRegionSet"] as? EndpointPropertyValue,
122+
case let .array(regions) = value {
123+
self.signingRegionSet = regions.compactMap { element in
124+
if case let .string(region) = element {
125+
return region
126+
}
127+
return nil
128+
}
129+
} else {
130+
self.signingRegionSet = nil
131+
}
132+
133+
// Extract disableDoubleEncoding
134+
if let value = dictionary["disableDoubleEncoding"] as? EndpointPropertyValue,
135+
case let .bool(flag) = value {
136+
self.disableDoubleEncoding = flag
137+
} else {
138+
self.disableDoubleEncoding = nil
139+
}
92140
}
93141
}
94142

0 commit comments

Comments
 (0)