Skip to content

Commit 6f2aac2

Browse files
committed
Add support for Windows
CoreFoundation isn't API on Windows, so compile it out in that case. All tests pass with these changes.
1 parent e8bc5ed commit 6f2aac2

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

.github/workflows/main.yml

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
1717
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
1818
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
19+
windows_6_0_enabled: true
20+
windows_nightly_6_1_enabled: true
21+
windows_nightly_main_enabled: true
22+
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
23+
windows_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
24+
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
1925

2026
integration-test:
2127
name: Integration test

.github/workflows/pull_request.yml

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ jobs:
2020
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
2121
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
2222
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
23+
windows_6_0_enabled: true
24+
windows_nightly_6_1_enabled: true
25+
windows_nightly_main_enabled: true
26+
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
27+
windows_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
28+
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
2329

2430
integration-test:
2531
name: Integration test

Sources/OpenAPIRuntime/Base/OpenAPIValue.swift

+6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import class Foundation.NSNull
1919
@preconcurrency import class Foundation.NSNull
2020
#endif
2121
import class Foundation.NSNumber
22+
#if canImport(CoreFoundation)
2223
import CoreFoundation
2324
#endif
25+
#endif
2426

2527
/// A container for a value represented by JSON Schema.
2628
///
@@ -141,11 +143,13 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
141143
try container.encodeNil()
142144
return
143145
}
146+
#if canImport(CoreFoundation)
144147
if let nsNumber = value as? NSNumber {
145148
try encode(nsNumber, to: &container)
146149
return
147150
}
148151
#endif
152+
#endif
149153
switch value {
150154
case let value as Bool: try container.encode(value)
151155
case let value as Int: try container.encode(value)
@@ -162,6 +166,7 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
162166
)
163167
}
164168
}
169+
#if canImport(CoreFoundation)
165170
/// Encodes the provided NSNumber based on its internal representation.
166171
/// - Parameters:
167172
/// - value: The NSNumber that boxes one of possibly many different types of values.
@@ -198,6 +203,7 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
198203
}
199204
}
200205
}
206+
#endif
201207

202208
// MARK: Equatable
203209

Tests/OpenAPIRuntimeTests/Base/Test_OpenAPIValue.swift

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ final class Test_OpenAPIValue: Test_Runtime {
7878
try _testPrettyEncoded(container, expectedJSON: expectedString)
7979
}
8080

81+
#if canImport(CoreFoundation)
8182
func testEncodingNSNumber() throws {
8283
func assertEncodedCF(
8384
_ value: CFNumber,
@@ -129,6 +130,7 @@ final class Test_OpenAPIValue: Test_Runtime {
129130
XCTAssertThrowsError(try assertEncodedCF(kCFNumberPositiveInfinity, as: "-"))
130131
}
131132
#endif
133+
#endif
132134
func testEncoding_container_failure() throws {
133135
struct Foobar: Equatable {}
134136
XCTAssertThrowsError(try OpenAPIValueContainer(unvalidatedValue: Foobar())) { error in

0 commit comments

Comments
 (0)