Skip to content

Commit cbf3926

Browse files
aryan-25glbrntt
andauthored
Remove platform requirements (#4)
### Motivation The 26.0 platform requirements are only present due to the `swift-nio-quic` dependency. Moreover, this dependency is only required by the `H3IntegrationTests` test target. Following from apple/swift-nio-quic#18, we can now transitively drop the platform requirements in this repo and gate declarations using `swift-nio-quic` APIs in `H3IntegrationTests` behind an `@available(anyAppleOS 26, *)` guard. ### Modifications - Updated the `swift-nio-quic` dependency to point to the branch of apple/swift-nio-quic#18. - Removed the `platform` declaration in `Package.swift`. - Added an `@available(anyAppleOS 26, *)` guard to all declarations in `H3IntegrationTests` using `swift-nio-quic` APIs. - Added an `@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)` guard to all declarations behind the `HTTP3AsyncInterface` SPI (to match the availability of `AsyncStreaming`). ### Result `swift-nio-http3` can be used without 26.0 platform requirements. --------- Co-authored-by: George Barnett <gbarnett@apple.com>
1 parent 75e1270 commit cbf3926

8 files changed

Lines changed: 42 additions & 30 deletions

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import PackageDescription
1818
var swiftSettings: [PackageDescription.SwiftSetting] = [
1919
.enableUpcomingFeature("ExistentialAny"),
2020
.enableUpcomingFeature("InternalImportsByDefault"),
21+
.enableExperimentalFeature("AnyAppleOSAvailability"),
2122
]
2223

2324
let package = Package(
2425
name: "swift-nio-http3",
25-
platforms: [.macOS("26.0"), .iOS("26.0"), .tvOS("26.0"), .watchOS("26.0"), .visionOS("26.0")],
2626
products: [
2727
.library(name: "NIOHTTP3", targets: ["NIOHTTP3"])
2828
],

Sources/NIOHTTP3/HTTP3ConnectionHandler.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public final class HTTP3ConnectionHandler<StreamCreator: QUICStreamCreator & Sen
185185
/// - connection: An instance of ``HTTP3ServerConnection`` which inbound connections can be vended to.
186186
/// - Returns: A ``HTTP3ConnectionHandler``.
187187
@_spi(HTTP3AsyncInterface)
188+
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
188189
public static func server<Output: Sendable>(
189190
eventLoop: any EventLoop,
190191
configuration: HTTP3ServerConfiguration,

Sources/NIOHTTP3/HTTP3ConnectionMultiplexer.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public import NIOQUICHelpers
2121
// Allow creating outbound push streams.
2222
/// A HTTP/3 connection from a servers side. Allows iterating inbound streams.
2323
@_spi(HTTP3AsyncInterface)
24+
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
2425
public struct HTTP3ServerConnection<Output: Sendable, StreamCreator: QUICStreamCreator>: Sendable {
2526
/// Channel initializer called for each new inbound stream.
2627
private let inboundStreamInitializer: @Sendable (HTTP3StreamInitializerParameters) -> EventLoopFuture<Output>
@@ -85,6 +86,7 @@ extension HTTP3ServerConnection.InboundStreams.AsyncIterator: Sendable {}
8586
// Allow iterating incoming push streams.
8687
/// A HTTP/3 connection from a clients side. Allows creating outbound request streams.
8788
@_spi(HTTP3AsyncInterface)
89+
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
8890
public struct HTTP3ClientConnection<
8991
Output: Sendable,
9092
StreamCreator: QUICStreamCreator & SendableMetatype
@@ -144,6 +146,7 @@ package protocol StreamMultiplexerContinuation: Sendable {
144146
func finish()
145147
}
146148

149+
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
147150
extension HTTP3ServerConnection: StreamMultiplexerContinuation {
148151
package func initialize(parameters: HTTP3StreamInitializerParameters) -> EventLoopFuture<any Sendable> {
149152
self.inboundStreamInitializer(parameters).map { $0 as any Sendable }
@@ -163,6 +166,7 @@ extension HTTP3ServerConnection: StreamMultiplexerContinuation {
163166
/// You can use this type to wrap a QUIC implementation. Have the QUIC implementation call ``yield(connection:)`` and ``finish()`` as appropriate.
164167
/// Then, you can easily iterate through incoming connections and handle them.
165168
@_spi(HTTP3AsyncInterface)
169+
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
166170
public struct HTTP3ServerConnectionMultiplexer<Output: Sendable, StreamCreator: QUICStreamCreator>: Sendable {
167171
/// The inboundConnections' continuation.
168172
private let inboundConnectionsContinuation: AsyncStream<HTTP3ServerConnection<Output, StreamCreator>>.Continuation
@@ -219,6 +223,7 @@ extension HTTP3ServerConnectionMultiplexer.InboundConnections.AsyncIterator: Sen
219223

220224
/// Implementations of QUIC should implement this protocol to be able to use the HTTP3ClientConnectionMultiplexer.
221225
@_spi(HTTP3AsyncInterface)
226+
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
222227
public protocol HTTP3ConnectionCreator {
223228
/// Create a new QUIC connection using the parameters provided.
224229
/// - Parameters:
@@ -235,6 +240,7 @@ public protocol HTTP3ConnectionCreator {
235240

236241
/// Allows you to create outbound connections as a client.
237242
@_spi(HTTP3AsyncInterface)
243+
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
238244
public struct HTTP3ClientConnectionMultiplexer<
239245
ConnectionCreator: HTTP3ConnectionCreator & SendableMetatype,
240246
StreamCreator: QUICStreamCreator

Tests/H3IntegrationTests/AsyncEndToEndTests.swift

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,16 @@ import struct NIOQUIC.QUICStreamCreator
2828
struct AsyncEndToEndTests {
2929
private let eventLoopGroup = MultiThreadedEventLoopGroup.singleton
3030

31-
private static func supportsAsyncInterface() -> Bool {
32-
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, macCatalyst 13.0, *) {
33-
return true
34-
} else {
35-
return false
36-
}
37-
}
38-
3931
private static let standardAuthenticationConfigurations: [AuthenticationConfiguration] = {
4032
[.keys, .certs]
4133
}()
4234

43-
@Test(
44-
.enabled(if: Self.supportsAsyncInterface()),
45-
arguments: Self.standardAuthenticationConfigurations
46-
)
35+
@Test(arguments: Self.standardAuthenticationConfigurations)
36+
@available(anyAppleOS 26, *)
4737
func asyncRoundtrip(authenticationConfiguration: AuthenticationConfiguration) async throws {
4838
let serverLogger = Logger(label: "Server")
4939
let clientLogger = Logger(label: "Client")
5040

51-
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, macCatalyst 13.0, *) else {
52-
fatalError("Test shouldn't be enabled on this platform")
53-
}
54-
5541
let credentials = try TestCertificates.makeCredentials(for: authenticationConfiguration)
5642
let serverName: String
5743
switch credentials {
@@ -138,16 +124,13 @@ struct AsyncEndToEndTests {
138124
}
139125
}
140126

141-
@Test(.enabled(if: Self.supportsAsyncInterface()), arguments: Self.standardAuthenticationConfigurations)
127+
@Test(arguments: Self.standardAuthenticationConfigurations)
128+
@available(anyAppleOS 26, *)
142129
func goawayMidRequestWithHighID(authenticationConfiguration: AuthenticationConfiguration) async throws {
143130
// Send a goaway to the client in the middle of a request. See that the client can not make further requests.
144131
let serverLogger = Logger(label: "Server")
145132
let clientLogger = Logger(label: "Client")
146133

147-
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, macCatalyst 13.0, *) else {
148-
fatalError("Test shouldn't be enabled on this platform")
149-
}
150-
151134
let credentials = try TestCertificates.makeCredentials(for: authenticationConfiguration)
152135
let serverName: String
153136
switch credentials {
@@ -245,17 +228,14 @@ struct AsyncEndToEndTests {
245228
try await clientChannel.close()
246229
}
247230

248-
@Test(.enabled(if: Self.supportsAsyncInterface()), arguments: Self.standardAuthenticationConfigurations)
231+
@Test(arguments: Self.standardAuthenticationConfigurations)
232+
@available(anyAppleOS 26, *)
249233
func goawayMidRequest(authenticationConfiguration: AuthenticationConfiguration) async throws {
250234
// Send a goaway to a client during a request, such that the goaway affects the request in flight.
251235
// See that the server rejects the request.
252236
let serverLogger = Logger(label: "Server")
253237
let clientLogger = Logger(label: "Client")
254238

255-
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, macCatalyst 13.0, *) else {
256-
fatalError("Test shouldn't be enabled on this platform")
257-
}
258-
259239
let credentials = try TestCertificates.makeCredentials(for: authenticationConfiguration)
260240
let serverName: String
261241
switch credentials {
@@ -385,6 +365,7 @@ struct AsyncEndToEndTests {
385365

386366
// MARK: - Helper Functions
387367

368+
@available(anyAppleOS 26, *)
388369
private func makeHTTP3Server(
389370
credentials: Credentials,
390371
settings: HTTP3Settings,
@@ -473,6 +454,7 @@ struct AsyncEndToEndTests {
473454
}
474455
}
475456

457+
@available(anyAppleOS 26, *)
476458
private func makeHTTP3Client(
477459
credentials: Credentials,
478460
settings: HTTP3Settings,

Tests/H3IntegrationTests/EndToEndTests.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ struct EndToEndTests {
218218
}()
219219

220220
@Test(arguments: Self.standardAuthenticationConfigurations)
221+
@available(anyAppleOS 26, *)
221222
func testSettingsFrame(authenticationConfiguration: AuthenticationConfiguration) async throws {
222223
let host = "127.0.0.1"
223224

@@ -304,6 +305,7 @@ struct EndToEndTests {
304305
.disabled("See DynamicTable document in NIOHTTP3 module"),
305306
arguments: Self.standardAuthenticationConfigurations
306307
)
308+
@available(anyAppleOS 26, *)
307309
func testRoundtripWithSlowDynamicTable(authenticationConfiguration: AuthenticationConfiguration) async throws {
308310
let host = "127.0.0.1"
309311

@@ -524,6 +526,7 @@ struct EndToEndTests {
524526
@Test(
525527
arguments: Self.standardAuthenticationConfigurations
526528
)
529+
@available(anyAppleOS 26, *)
527530
func testRoundtripWithoutDynamicTable(authenticationConfiguration: AuthenticationConfiguration) async throws {
528531
let host = "127.0.0.1"
529532

@@ -629,6 +632,7 @@ struct EndToEndTests {
629632
@Test(
630633
arguments: Self.standardAuthenticationConfigurations
631634
)
635+
@available(anyAppleOS 26, *)
632636
func testConnectionError(authenticationConfiguration: AuthenticationConfiguration) async throws {
633637
let host = "127.0.0.1"
634638

@@ -685,6 +689,7 @@ struct EndToEndTests {
685689
@Test(
686690
arguments: Self.standardAuthenticationConfigurations
687691
)
692+
@available(anyAppleOS 26, *)
688693
func testServerClosesConnection(authenticationConfiguration: AuthenticationConfiguration) async throws {
689694
let host = "127.0.0.1"
690695

@@ -732,6 +737,7 @@ struct EndToEndTests {
732737
@Test(
733738
arguments: Self.standardAuthenticationConfigurations
734739
)
740+
@available(anyAppleOS 26, *)
735741
func testClosingConnectionAlsoClosesStreams(authenticationConfiguration: AuthenticationConfiguration) async throws {
736742
let host = "127.0.0.1"
737743

@@ -786,6 +792,7 @@ struct EndToEndTests {
786792
@Test(
787793
arguments: Self.standardAuthenticationConfigurations
788794
)
795+
@available(anyAppleOS 26, *)
789796
func testServerClosesConnectionWithActiveStream(
790797
authenticationConfiguration: AuthenticationConfiguration
791798
) async throws {
@@ -853,6 +860,7 @@ struct EndToEndTests {
853860
@Test(
854861
arguments: Self.standardAuthenticationConfigurations
855862
)
863+
@available(anyAppleOS 26, *)
856864
func testStreamError(authenticationConfiguration: AuthenticationConfiguration) async throws {
857865
let host = "127.0.0.1"
858866

@@ -924,6 +932,7 @@ struct EndToEndTests {
924932
@Test(
925933
arguments: Self.standardAuthenticationConfigurations
926934
)
935+
@available(anyAppleOS 26, *)
927936
func testUnknownIncomingStream(authenticationConfiguration: AuthenticationConfiguration) async throws {
928937
let host = "127.0.0.1"
929938

@@ -977,10 +986,11 @@ struct EndToEndTests {
977986
try await serverChannel.close()
978987
}
979988

989+
// This is always an error; clients must not open push streams to servers.
980990
@Test(
981991
arguments: Self.standardAuthenticationConfigurations
982992
)
983-
// This is always an error; clients must not open push streams to servers.
993+
@available(anyAppleOS 26, *)
984994
func testIncomingPushStreamOnServer(authenticationConfiguration: AuthenticationConfiguration) async throws {
985995
let host = "127.0.0.1"
986996

@@ -1034,10 +1044,11 @@ struct EndToEndTests {
10341044
try await serverChannel.close()
10351045
}
10361046

1047+
// This is an error because the client hasn't specified that it wants to receive push (by sending a MAX_PUSH_ID frame)
10371048
@Test(
10381049
arguments: Self.standardAuthenticationConfigurations
10391050
)
1040-
// This is an error because the client hasn't specified that it wants to receive push (by sending a MAX_PUSH_ID frame)
1051+
@available(anyAppleOS 26, *)
10411052
func testIncomingPushStreamOnClient(authenticationConfiguration: AuthenticationConfiguration) async throws {
10421053
let host = "127.0.0.1"
10431054

@@ -1124,6 +1135,7 @@ struct EndToEndTests {
11241135
.disabled("See DynamicTable document in NIOHTTP3 module"),
11251136
arguments: Self.standardAuthenticationConfigurations
11261137
)
1138+
@available(anyAppleOS 26, *)
11271139
func testBadQPACKInstruction(authenticationConfiguration: AuthenticationConfiguration) async throws {
11281140
let host = "127.0.0.1"
11291141

@@ -1192,10 +1204,11 @@ struct EndToEndTests {
11921204
try await serverChannel.close()
11931205
}
11941206

1207+
// If the connection handler gets a shouldquiesce event then the stream handlers should also
11951208
@Test(
11961209
arguments: Self.standardAuthenticationConfigurations
11971210
)
1198-
// If the connection handler gets a shouldquiesce event then the stream handlers should also
1211+
@available(anyAppleOS 26, *)
11991212
func testForwardShouldQuiesce(authenticationConfiguration: AuthenticationConfiguration) async throws {
12001213
let host = "127.0.0.1"
12011214

@@ -1254,6 +1267,7 @@ struct EndToEndTests {
12541267
@Test(
12551268
arguments: Self.standardAuthenticationConfigurations
12561269
)
1270+
@available(anyAppleOS 26, *)
12571271
func testNoOutboundRequestsAfterGoawayReceived(
12581272
authenticationConfiguration: AuthenticationConfiguration
12591273
) async throws {
@@ -1377,6 +1391,7 @@ struct EndToEndTests {
13771391
@Test(
13781392
arguments: Self.standardAuthenticationConfigurations
13791393
)
1394+
@available(anyAppleOS 26, *)
13801395
func testControlStreamClosed(authenticationConfiguration: AuthenticationConfiguration) async throws {
13811396
let host = "127.0.0.1"
13821397

@@ -1461,6 +1476,7 @@ struct EndToEndTests {
14611476

14621477
// MARK: - Helper Functions
14631478

1479+
@available(anyAppleOS 26, *)
14641480
private func makeServer(
14651481
credentials: Credentials,
14661482
host: String,
@@ -1491,6 +1507,7 @@ struct EndToEndTests {
14911507
)
14921508
}
14931509

1510+
@available(anyAppleOS 26, *)
14941511
private func makeClient(
14951512
credentials: Credentials,
14961513
host: String,
@@ -1515,6 +1532,7 @@ struct EndToEndTests {
15151532
)
15161533
}
15171534

1535+
@available(anyAppleOS 26, *)
15181536
private static func createHTTP3ClientChannel(
15191537
eventLoopGroup: any EventLoopGroup,
15201538
host: String,
@@ -1563,6 +1581,7 @@ struct EndToEndTests {
15631581
return try await httpChannelFuture.get()
15641582
}
15651583

1584+
@available(anyAppleOS 26, *)
15661585
private static func createHTTP3ServerChannel(
15671586
eventLoopGroup: any EventLoopGroup,
15681587
host: String,

Tests/H3IntegrationTests/HTTP3+NIOQUIC.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import struct NIOQUIC.QUICStreamCreator
2828
typealias QUICHTTP3ConnectionHandler = HTTP3ConnectionHandler<QUICStreamCreator>
2929

3030
// MARK: Configure with async interface
31+
@available(anyAppleOS 26, *)
3132
extension ChannelPipeline.SynchronousOperations {
3233
/// Setup a HTTP/3 server pipeline on a UDP channel.
3334
///
@@ -201,6 +202,7 @@ extension ChannelPipeline.SynchronousOperations {
201202

202203
// MARK: Configure without async interface
203204

205+
@available(anyAppleOS 26, *)
204206
extension ChannelPipeline.SynchronousOperations {
205207
/// Setup a HTTP/3 server pipeline on a UDP channel.
206208
///

Tests/H3IntegrationTests/QUICConfiguration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import class Foundation.FileManager
1616
import struct Foundation.UUID
1717
import struct NIOQUIC.QUICConfiguration
1818

19+
@available(anyAppleOS 26, *)
1920
extension QUICConfiguration {
2021
static func makeH3ServerConfig(
2122
serverName: String,

Tests/H3IntegrationTests/QUICConnectionCreator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import NIOQUICHelpers
2020

2121
typealias ConcreteQUICStreamCreator = NIOQUIC.QUICStreamCreator
2222

23+
@available(anyAppleOS 26, *)
2324
struct QUICConnectionCreator: HTTP3ConnectionCreator {
2425
let quicHandler: QUICHandler
2526
let connectionInitializer: @Sendable (any Channel, ConcreteQUICStreamCreator) -> EventLoopFuture<any Channel>

0 commit comments

Comments
 (0)