Skip to content

Commit b584583

Browse files
committed
refactor: select foundation modules by capability
1 parent ae3cce9 commit b584583

53 files changed

Lines changed: 213 additions & 195 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Package.swift‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,20 @@ let package = Package(
4848
.product(
4949
name: "FoundationEssentialsExtras",
5050
package: "FoundationEssentialsExtras",
51-
condition: .when(platforms: [.wasi])
51+
condition: .when(platforms: [.wasi, .linux, .android, .windows])
5252
),
5353
.product(
5454
name: "SAXParser",
5555
package: "xylem",
56-
condition: .when(platforms: [.wasi])
56+
condition: .when(platforms: [.wasi, .linux, .android, .windows])
5757
),
5858
.product(
5959
name: "XMLCore",
6060
package: "xylem",
61-
condition: .when(platforms: [.wasi])
61+
condition: .when(platforms: [.wasi, .linux, .android, .windows])
6262
),
6363
],
64-
path: "Source",
65-
swiftSettings: [
66-
.define(
67-
"FOUNDATION_ESSENTIALS_BUILD",
68-
.when(platforms: [.wasi])
69-
),
70-
]
64+
path: "Source"
7165
),
7266
.testTarget(
7367
name: "CoreGraphicsPolyfillTests",

‎Source/CoreGraphicsPolyfill.swift‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
// Created by khoi on 10/5/25.
66
//
77

8-
#if FOUNDATION_ESSENTIALS_BUILD
8+
#if canImport(FoundationEssentialsExtras)
99
import FoundationEssentialsExtras
10-
import WASILibc
1110
#else
1211
import Foundation
1312
#endif
1413

15-
#if FOUNDATION_ESSENTIALS_BUILD
14+
#if os(WASI)
15+
import WASILibc
16+
#elseif os(Linux) || os(Android)
17+
import Glibc
18+
#endif
19+
20+
#if canImport(FoundationEssentialsExtras)
1621
public typealias CGFloat = FoundationEssentialsExtras.CGFloat
1722
public typealias CGPoint = FoundationEssentialsExtras.CGPoint
1823
public typealias CGSize = FoundationEssentialsExtras.CGSize

‎Source/Model/Images/SVGDataImage.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
// Created by Alisa Mylnikova on 10/06/2021.
66
//
77

8-
#if FOUNDATION_ESSENTIALS_BUILD
9-
import FoundationEssentials
10-
#elseif os(WASI) || os(Linux) || os(Android)
11-
import Foundation
12-
#else
8+
#if canImport(SwiftUI)
139
import SwiftUI
1410
import Combine
11+
#elseif canImport(FoundationEssentials)
12+
import FoundationEssentials
13+
#else
14+
import Foundation
1515
#endif
1616

1717
public class SVGDataImage: SVGImage {

‎Source/Model/Images/SVGURLImage.swift‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
// Created by Alisa Mylnikova on 22/09/2021.
66
//
77

8-
#if FOUNDATION_ESSENTIALS_BUILD
8+
#if canImport(SwiftUI)
9+
import SwiftUI
10+
#elseif canImport(FoundationEssentials)
911
import FoundationEssentials
10-
#elseif os(WASI) || os(Linux) || os(Android)
11-
import Foundation
1212
#else
13-
import SwiftUI
13+
import Foundation
1414
#endif
1515

1616
public class SVGURLImage: SVGImage {

‎Source/Model/Nodes/SVGDefs.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#if FOUNDATION_ESSENTIALS_BUILD
2-
import FoundationEssentials
3-
#elseif os(WASI) || os(Linux) || os(Android)
4-
import Foundation
5-
#else
1+
#if canImport(SwiftUI)
62
import SwiftUI
73
import Combine
4+
#elseif canImport(FoundationEssentials)
5+
import FoundationEssentials
6+
#else
7+
import Foundation
88
#endif
99

1010
public class SVGDefs: SVGGroup {}

‎Source/Model/Nodes/SVGGroup.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#if FOUNDATION_ESSENTIALS_BUILD
2-
import FoundationEssentials
3-
#elseif os(WASI) || os(Linux) || os(Android)
4-
import Foundation
5-
#else
1+
#if canImport(SwiftUI)
62
import SwiftUI
73
import Combine
4+
#elseif canImport(FoundationEssentials)
5+
import FoundationEssentials
6+
#else
7+
import Foundation
88
#endif
99

1010
public class SVGGroup: SVGNode {

‎Source/Model/Nodes/SVGImage.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
// Created by Alisa Mylnikova on 03/06/2021.
66
//
77

8-
#if FOUNDATION_ESSENTIALS_BUILD
9-
import FoundationEssentials
10-
#elseif os(WASI) || os(Linux) || os(Android)
11-
import Foundation
12-
#else
8+
#if canImport(SwiftUI)
139
import SwiftUI
1410
import Combine
11+
#elseif canImport(FoundationEssentials)
12+
import FoundationEssentials
13+
#else
14+
import Foundation
1515
#endif
1616

1717
public class SVGImage: SVGNode {

‎Source/Model/Nodes/SVGMarker.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#if FOUNDATION_ESSENTIALS_BUILD
2-
import FoundationEssentials
3-
#elseif os(WASI) || os(Linux) || os(Android)
4-
import Foundation
5-
#else
1+
#if canImport(SwiftUI)
62
import SwiftUI
73
import Combine
4+
#elseif canImport(FoundationEssentials)
5+
import FoundationEssentials
6+
#else
7+
import Foundation
88
#endif
99

1010
public class SVGMarker: SVGGroup {

‎Source/Model/Nodes/SVGNode.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#if FOUNDATION_ESSENTIALS_BUILD
2-
import FoundationEssentials
3-
#elseif os(WASI) || os(Linux) || os(Android)
4-
import Foundation
5-
#else
1+
#if canImport(SwiftUI)
62
import SwiftUI
73
import Combine
4+
#elseif canImport(FoundationEssentials)
5+
import FoundationEssentials
6+
#else
7+
import Foundation
88
#endif
99

1010
public class SVGNode: SerializableElement {

‎Source/Model/Nodes/SVGShape.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#if FOUNDATION_ESSENTIALS_BUILD
2-
import FoundationEssentials
3-
#elseif os(WASI) || os(Linux) || os(Android)
4-
import Foundation
5-
#else
1+
#if canImport(SwiftUI)
62
import SwiftUI
73
import Combine
4+
#elseif canImport(FoundationEssentials)
5+
import FoundationEssentials
6+
#else
7+
import Foundation
88
#endif
99

1010
public class SVGShape: SVGNode {

0 commit comments

Comments
 (0)