@@ -17,6 +17,13 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
17
17
}
18
18
}
19
19
20
+ #if os(macOS)
21
+ // NOTE: #if os(macOS) check is not accurate if we are cross compiling for Linux platform. So we add an env key to specify it.
22
+ let buildForDarwinPlatform = envEnable ( " OPENSWIFTUI_BUILD_FOR_DARWIN_PLATFORM " , default: true )
23
+ #else
24
+ let buildForDarwinPlatform = envEnable ( " OPENSWIFTUI_BUILD_FOR_DARWIN_PLATFORM " )
25
+ #endif
26
+
20
27
// MARK: - Env and Config
21
28
22
29
let isXcodeEnv = Context . environment [ " __CFBundleIdentifier " ] == " com.apple.dt.Xcode "
@@ -72,11 +79,7 @@ if development {
72
79
73
80
// MARK: - [env] OPENSWIFTUI_LINK_COREUI
74
81
75
- #if os(macOS)
76
- let linkCoreUI = envEnable ( " OPENSWIFTUI_LINK_COREUI " , default: true )
77
- #else
78
- let linkCoreUI = envEnable ( " OPENSWIFTUI_LINK_COREUI " )
79
- #endif
82
+ let linkCoreUI = envEnable ( " OPENSWIFTUI_LINK_COREUI " , default: buildForDarwinPlatform)
80
83
81
84
if linkCoreUI {
82
85
sharedCSettings. append (
@@ -92,20 +95,11 @@ if linkCoreUI {
92
95
93
96
// MARK: - [env] OPENGSWIFTUI_SYMBOL_LOCATOR
94
97
95
- #if os(macOS)
96
- let symbolLocatorCondition = envEnable ( " OPENGSWIFTUI_SYMBOL_LOCATOR " , default: true )
97
- #else
98
- let symbolLocatorCondition = envEnable ( " OPENGSWIFTUI_SYMBOL_LOCATOR " )
99
- #endif
98
+ let symbolLocatorCondition = envEnable ( " OPENGSWIFTUI_SYMBOL_LOCATOR " , default: buildForDarwinPlatform)
100
99
101
100
// MARK: - [env] OPENGSWIFTUI_SWIFTUI_RENDER
102
101
103
- #if os(macOS)
104
- let swiftUIRenderCondition = envEnable ( " OPENSWIFTUI_SWIFTUI_RENDER " , default: true )
105
- #else
106
- let swiftUIRenderCondition = envEnable ( " OPENSWIFTUI_SWIFTUI_RENDER " )
107
- #endif
108
-
102
+ let swiftUIRenderCondition = envEnable ( " OPENSWIFTUI_SWIFTUI_RENDER " , default: buildForDarwinPlatform)
109
103
if swiftUIRenderCondition {
110
104
sharedCSettings. append ( . define( " _OPENSWIFTUI_SWIFTUI_RENDER " ) )
111
105
sharedCxxSettings. append ( . define( " _OPENSWIFTUI_SWIFTUI_RENDER " ) )
@@ -132,12 +126,7 @@ if warningsAsErrorsCondition {
132
126
133
127
// MARK: - [env] OPENSWIFTUI_LIBRARY_EVOLUTION
134
128
135
- #if os(macOS)
136
- let libraryEvolutionCondition = envEnable ( " OPENSWIFTUI_LIBRARY_EVOLUTION " , default: true )
137
- #else
138
- let libraryEvolutionCondition = envEnable ( " OPENSWIFTUI_LIBRARY_EVOLUTION " )
139
- #endif
140
-
129
+ let libraryEvolutionCondition = envEnable ( " OPENSWIFTUI_LIBRARY_EVOLUTION " , default: buildForDarwinPlatform)
141
130
if libraryEvolutionCondition {
142
131
// NOTE: -enable-library-evolution will cause module verify failure for `swift build`.
143
132
// Either set OPENSWIFTUI_LIBRARY_EVOLUTION=0 or add `-Xswiftc -no-verify-emitted-module-interface` after `swift build`
@@ -457,12 +446,7 @@ extension Target {
457
446
458
447
let useLocalDeps = envEnable ( " OPENSWIFTUI_USE_LOCAL_DEPS " )
459
448
460
- #if os(macOS)
461
- let attributeGraphCondition = envEnable ( " OPENGRAPH_ATTRIBUTEGRAPH " , default: true )
462
- #else
463
- let attributeGraphCondition = envEnable ( " OPENGRAPH_ATTRIBUTEGRAPH " )
464
- #endif
465
-
449
+ let attributeGraphCondition = envEnable ( " OPENGRAPH_ATTRIBUTEGRAPH " , default: buildForDarwinPlatform)
466
450
if attributeGraphCondition {
467
451
openSwiftUICoreTarget. addAGSettings ( )
468
452
openSwiftUITarget. addAGSettings ( )
@@ -474,12 +458,7 @@ if attributeGraphCondition {
474
458
openSwiftUIBridgeTestTarget. addAGSettings ( )
475
459
}
476
460
477
- #if os(macOS)
478
- let renderBoxCondition = envEnable ( " OPENBOX_RENDERBOX " , default: true )
479
- #else
480
- let renderBoxCondition = envEnable ( " OPENBOX_RENDERBOX " )
481
- #endif
482
-
461
+ let renderBoxCondition = envEnable ( " OPENBOX_RENDERBOX " , default: buildForDarwinPlatform)
483
462
if renderBoxCondition {
484
463
openSwiftUICoreTarget. addRBSettings ( )
485
464
openSwiftUITarget. addRBSettings ( )
@@ -525,11 +504,7 @@ if useLocalDeps {
525
504
package . dependencies += dependencies
526
505
}
527
506
528
- #if os(macOS)
529
- let openCombineCondition = envEnable ( " OPENSWIFTUI_OPENCOMBINE " )
530
- #else
531
- let openCombineCondition = envEnable ( " OPENSWIFTUI_OPENCOMBINE " , default: true )
532
- #endif
507
+ let openCombineCondition = envEnable ( " OPENSWIFTUI_OPENCOMBINE " , default: !buildForDarwinPlatform)
533
508
if openCombineCondition {
534
509
package . dependencies. append (
535
510
. package ( url: " https://github.com/OpenSwiftUIProject/OpenCombine.git " , from: " 0.15.0 " )
@@ -538,11 +513,7 @@ if openCombineCondition {
538
513
openSwiftUITarget. addOpenCombineSettings ( )
539
514
}
540
515
541
- #if os(macOS)
542
- let swiftLogCondition = envEnable ( " OPENSWIFTUI_SWIFT_LOG " )
543
- #else
544
- let swiftLogCondition = envEnable ( " OPENSWIFTUI_SWIFT_LOG " , default: true )
545
- #endif
516
+ let swiftLogCondition = envEnable ( " OPENSWIFTUI_SWIFT_LOG " , default: !buildForDarwinPlatform)
546
517
if swiftLogCondition {
547
518
package . dependencies. append (
548
519
. package ( url: " https://github.com/apple/swift-log " , from: " 1.5.3 " )
@@ -551,11 +522,7 @@ if swiftLogCondition {
551
522
openSwiftUITarget. addSwiftLogSettings ( )
552
523
}
553
524
554
- #if os(macOS)
555
- let swiftCryptoCondition = envEnable ( " OPENSWIFTUI_SWIFT_CRYPTO " )
556
- #else
557
- let swiftCryptoCondition = envEnable ( " OPENSWIFTUI_SWIFT_CRYPTO " , default: true )
558
- #endif
525
+ let swiftCryptoCondition = envEnable ( " OPENSWIFTUI_SWIFT_CRYPTO " , default: !buildForDarwinPlatform)
559
526
if swiftCryptoCondition {
560
527
package . dependencies. append (
561
528
. package ( url: " https://github.com/apple/swift-crypto.git " , from: " 3.8.0 " )
0 commit comments