Skip to content

Commit 160c464

Browse files
committed
Explicitly add FoundationSupport trait
1 parent 974f2dc commit 160c464

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,21 @@ jobs:
122122
let package = Package(
123123
name: "DownstreamTestNoNIO",
124124
dependencies: [
125-
.package(path: "../IkigaJSON"),
125+
.package(path: "../IkigaJSON", traits: ["FoundationSupport"]),
126126
],
127127
targets: [
128128
.executableTarget(
129129
name: "DownstreamTestNoNIO",
130130
dependencies: [
131-
.product(
132-
name: "IkigaJSON",
133-
package: "IkigaJSON",
134-
traits: ["FoundationSupport"]
135-
),
131+
.product(name: "IkigaJSON", package: "IkigaJSON"),
136132
]
137133
)
138134
]
139135
)
140136
PKGEOF
141137
mkdir -p downstream-test-no-nio/Sources/DownstreamTestNoNIO
142138
cat > downstream-test-no-nio/Sources/DownstreamTestNoNIO/main.swift << 'SRCEOF'
139+
import Foundation
143140
import IkigaJSON
144141
145142
struct Point: Decodable { let x: Int; let y: Int }

Package.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ let package = Package(
2121
targets: ["_JSONCore"]
2222
),
2323
],
24+
traits: [
25+
.trait(name: "FoundationSupport", enabledTraits: [])
26+
],
2427
dependencies: [
2528
// Dependencies declare other packages that this package depends on.
2629
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0")
@@ -38,17 +41,20 @@ let package = Package(
3841
.target(
3942
name: "_NIOJSON",
4043
dependencies: [
41-
.product(name: "NIOCore", package: "swift-nio"),
42-
.product(name: "NIOFoundationCompat", package: "swift-nio"),
44+
.product(name: "NIOCore", package: "swift-nio", condition: .when(traits: ["FoundationSupport"])),
45+
.product(name: "NIOFoundationCompat", package: "swift-nio", condition: .when(traits: ["FoundationSupport"])),
4346
.target(name: "_JSONCore"),
4447
]
4548
),
4649
.target(
4750
name: "IkigaJSON",
4851
dependencies: [
49-
.product(name: "NIOCore", package: "swift-nio"),
52+
.product(name: "NIOCore", package: "swift-nio", condition: .when(traits: ["FoundationSupport"])),
5053
.target(name: "_JSONCore"),
51-
.target(name: "_NIOJSON"),
54+
.target(name: "_NIOJSON", condition: .when(traits: ["FoundationSupport"])),
55+
],
56+
swiftSettings: [
57+
.define("FOUNDATION_SUPPORT", .when(traits: ["FoundationSupport"])),
5258
]
5359
),
5460
.testTarget(

Sources/IkigaJSON/Exports.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
#if FOUNDATION_SUPPORT
12
@_exported import _NIOJSON
3+
#else
4+
@_exported import _JSONCore
5+
#endif

0 commit comments

Comments
 (0)