Skip to content

Commit 5ffc0fe

Browse files
authored
Add missing availability annotations (#9)
This PR adds missing availability annotations after removing platform requirements from the package manifest. It also re-enables missing availability warnings in Xcode (which had been turned off). This was hiding a Sendability issue for some reason, but I'll fix that up in a follow-up PR since it's quite complex.
1 parent 335d55f commit 5ffc0fe

15 files changed

+21
-6
lines changed

Package.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ let extraSettings: [SwiftSetting] = [
1010
.enableUpcomingFeature("InferIsolatedConformances"),
1111
.enableUpcomingFeature("ExistentialAny"),
1212
.enableUpcomingFeature("MemberImportVisibility"),
13-
.enableUpcomingFeature("InternalImportsByDefault"),
14-
.unsafeFlags([
15-
"-Xfrontend",
16-
"-disable-availability-checking",
17-
]),
13+
.enableUpcomingFeature("InternalImportsByDefault")
1814
]
1915

2016
let package = Package(

Sources/Example/Example.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Middleware
88
import X509
99

1010
@main
11+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
1112
struct Example {
1213
static func main() async throws {
1314
try await serve()
@@ -68,6 +69,7 @@ struct Example {
6869

6970
// MARK: - Server Extensions
7071

72+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
7173
extension Server {
7274
/// Serve HTTP requests using a middleware chain built with the provided builder
7375
/// This method handles the type inference for HTTP middleware components

Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import HTTPTypes
33
import Logging
44
import Middleware
55

6+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
67
struct HTTPRequestLoggingMiddleware<
78
RequestConludingAsyncReader: ConcludingAsyncReader,
89
ResponseConcludingAsyncWriter: ConcludingAsyncWriter & ~Copyable
@@ -62,6 +63,7 @@ where
6263
}
6364
}
6465

66+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
6567
struct HTTPRequestLoggingConcludingAsyncReader<
6668
Base: ConcludingAsyncReader
6769
>: ConcludingAsyncReader
@@ -123,6 +125,7 @@ where
123125
}
124126
}
125127

128+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
126129
struct HTTPResponseLoggingConcludingAsyncWriter<
127130
Base: ConcludingAsyncWriter & ~Copyable
128131
>: ConcludingAsyncWriter, ~Copyable

Sources/Example/Middlewares/RouteHandlerMiddleware.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import HTTPServer
22
import HTTPTypes
33
import Middleware
44

5+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
56
struct RouteHandlerMiddleware<
67
RequestConcludingAsyncReader: ConcludingAsyncReader & Copyable,
78
ResponseConcludingAsyncWriter: ConcludingAsyncWriter & ~Copyable,

Sources/Example/Middlewares/TimeoutMiddleware.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Middleware
22

3+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
34
struct TimeoutMiddleware<Input>: Middleware {
45
func intercept(input: Input, next: (Input) async throws -> Void) async throws {
56
try await withoutActuallyEscaping(next) { next in
@@ -21,6 +22,7 @@ package struct TimeOutError: Error {
2122
var underlying: any Error
2223
}
2324

25+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
2426
public func withTimeout<T: Sendable, Clock: _Concurrency.Clock>(
2527
in timeout: Clock.Duration,
2628
clock: Clock,

Sources/Example/Middlewares/TracingMiddleware.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import HTTPTypes
22
import Middleware
33
import Tracing
44

5+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
56
struct TracingMiddleware<Input>: Middleware {
67
func intercept(
78
input: Input,

Sources/HTTPServer/AsyncPrimitives/AsyncReader.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
///
33
/// ``AsyncReader`` defines an interface for types that can asynchronously read elements
44
/// of a specified type from a source.
5+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
56
public protocol AsyncReader<ReadElement, ReadFailure> {
67
/// The type of elements that can be read by this reader.
78
associatedtype ReadElement: ~Copyable, ~Escapable
@@ -44,6 +45,7 @@ public protocol AsyncReader<ReadElement, ReadFailure> {
4445
) async throws(ReadFailure) -> Return
4546
}
4647

48+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
4749
extension AsyncReader {
4850
/// Collects elements from the reader up to a specified limit and processes them with a body function.
4951
///

Sources/HTTPServer/AsyncPrimitives/ConcludingAsyncReader.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/// provide a conclusive element after all reads are completed. This is particularly useful
55
/// for streams that have meaningful completion states beyond just terminating, such as
66
/// HTTP responses that include headers after the body is fully read.
7+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
78
public protocol ConcludingAsyncReader<Underlying, FinalElement> {
89
/// The underlying asynchronous reader type that produces elements.
910
associatedtype Underlying: AsyncReader, ~Copyable, ~Escapable
@@ -37,6 +38,7 @@ public protocol ConcludingAsyncReader<Underlying, FinalElement> {
3738
) async throws -> (Return, FinalElement)
3839
}
3940

41+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
4042
extension ConcludingAsyncReader {
4143
/// Processes the underlying async reader until completion and returns only the final element.
4244
///

Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import NIOHTTPTypes
99
/// and concluding with the HTTP trailer fields received at the end of the request. This type
1010
/// follows the ``ConcludingAsyncReader`` pattern, which allows for asynchronous consumption of
1111
/// a stream with a conclusive final element.
12+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
1213
public struct HTTPRequestConcludingAsyncReader: ConcludingAsyncReader {
1314
/// A reader for HTTP request body chunks that implements the ``AsyncReader`` protocol.
1415
///

Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import NIOHTTPTypes
1111
///
1212
/// This writer is designed to work with HTTP responses where the body is streamed in chunks
1313
/// and potentially followed by trailer fields.
14+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
1415
public struct HTTPResponseConcludingAsyncWriter: ConcludingAsyncWriter, ~Copyable {
1516
/// A writer for HTTP response body chunks that implements the ``AsyncWriter`` protocol.
1617
///

0 commit comments

Comments
 (0)