Skip to content

Commit 5ee8f2d

Browse files
authored
Move to FoundationEssentials (#59)
Uses `FoundationEssentials` instead of `Foundation`. Also removes `NIOFoundationCompat`, because it did appear to be used, and that pulled in the entire Foundation. Also disabled the default traits for the `OpenAPIRuntime` to prevent linking Foundation.
1 parent 502e303 commit 5ee8f2d

5 files changed

Lines changed: 75 additions & 10 deletions

File tree

.licenseignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
Package.swift
1919
**/Package.swift
2020
Package@-*.swift
21+
Package@swift-*.swift
2122
**/Package@-*.swift
23+
**/Package@swift-*.swift
2224
Package.resolved
2325
**/Package.resolved
2426
Makefile

.swiftformatignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
**Package.swift
2+
**Package@swift-*.swift

Package.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:6.0
1+
// swift-tools-version:6.1
22
//===----------------------------------------------------------------------===//
33
//
44
// This source file is part of the SwiftOpenAPIGenerator open source project
@@ -29,7 +29,7 @@ let package = Package(
2929
dependencies: [
3030
.package(url: "https://github.com/apple/swift-nio", from: "2.58.0"),
3131
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0"),
32-
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
32+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.11.0", traits: []),
3333
.package(url: "https://github.com/apple/swift-http-types", from: "1.0.0"),
3434
],
3535
targets: [
@@ -39,7 +39,6 @@ let package = Package(
3939
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
4040
.product(name: "HTTPTypes", package: "swift-http-types"),
4141
.product(name: "AsyncHTTPClient", package: "async-http-client"),
42-
.product(name: "NIOFoundationCompat", package: "swift-nio"),
4342
],
4443
swiftSettings: swiftSettings
4544
),

Package@swift-6.0.swift

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// swift-tools-version:6.0
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the SwiftOpenAPIGenerator open source project
5+
//
6+
// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of SwiftOpenAPIGenerator project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
import Foundation
16+
import PackageDescription
17+
18+
// General Swift-settings for all targets.
19+
let swiftSettings: [SwiftSetting] = [
20+
// https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md
21+
// Require `any` for existential types.
22+
.enableUpcomingFeature("ExistentialAny")
23+
]
24+
25+
let package = Package(
26+
name: "swift-openapi-async-http-client",
27+
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
28+
products: [.library(name: "OpenAPIAsyncHTTPClient", targets: ["OpenAPIAsyncHTTPClient"])],
29+
dependencies: [
30+
.package(url: "https://github.com/apple/swift-nio", from: "2.58.0"),
31+
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0"),
32+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
33+
.package(url: "https://github.com/apple/swift-http-types", from: "1.0.0"),
34+
],
35+
targets: [
36+
.target(
37+
name: "OpenAPIAsyncHTTPClient",
38+
dependencies: [
39+
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
40+
.product(name: "HTTPTypes", package: "swift-http-types"),
41+
.product(name: "AsyncHTTPClient", package: "async-http-client"),
42+
],
43+
swiftSettings: swiftSettings
44+
),
45+
.testTarget(
46+
name: "OpenAPIAsyncHTTPClientTests",
47+
dependencies: ["OpenAPIAsyncHTTPClient"],
48+
swiftSettings: swiftSettings
49+
),
50+
]
51+
)
52+
53+
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
54+
for target in package.targets {
55+
switch target.type {
56+
case .regular, .test, .executable:
57+
var settings = target.swiftSettings ?? []
58+
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
59+
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
60+
target.swiftSettings = settings
61+
case .macro, .plugin, .system, .binary: () // not applicable
62+
@unknown default: () // we don't know what to do here, do nothing
63+
}
64+
}// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //

Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ import OpenAPIRuntime
1515
import AsyncHTTPClient
1616
import NIOCore
1717
import NIOHTTP1
18-
import NIOFoundationCompat
1918
import HTTPTypes
20-
#if canImport(Darwin)
21-
import Foundation
19+
#if canImport(FoundationEssentials)
20+
@preconcurrency import struct FoundationEssentials.URL
21+
import struct FoundationEssentials.URLComponents
22+
import struct FoundationEssentials.Data
23+
import protocol FoundationEssentials.LocalizedError
2224
#else
23-
@preconcurrency import struct Foundation.URL
24-
import struct Foundation.URLComponents
25-
import struct Foundation.Data
26-
import protocol Foundation.LocalizedError
25+
import Foundation
2726
#endif
2827

2928
/// A client transport that performs HTTP operations using the HTTPClient type

0 commit comments

Comments
 (0)