Skip to content

Commit e9183f7

Browse files
authored
Fix CoreUI import issue and SymbolLocator build issue on Linux with Swift 6.1 (#279)
1 parent d4d98b0 commit e9183f7

File tree

6 files changed

+65
-20
lines changed

6 files changed

+65
-20
lines changed

Package.resolved

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"originHash" : "8917cbaeeda8db57a8ea78c2771eb811ef20031946167d085ed5773330885409",
2+
"originHash" : "c72e2bc714f92bcf02092961f7be834040b491a370d9391bb55c683896efa9b3",
33
"pins" : [
44
{
55
"identity" : "darwinprivateframeworks",
@@ -42,8 +42,8 @@
4242
"kind" : "remoteSourceControl",
4343
"location" : "https://github.com/OpenSwiftUIProject/SymbolLocator.git",
4444
"state" : {
45-
"revision" : "ab226a25d84cd3c9f7286bec2c1a1ba8eea957c4",
46-
"version" : "0.1.0"
45+
"revision" : "1bd1a26ef304337ad2dbb4a947593d642f71ed8a",
46+
"version" : "0.2.0"
4747
}
4848
}
4949
],

Package.swift

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ if development {
7373
// MARK: - [env] OPENSWIFTUI_LINK_COREUI
7474

7575
#if os(macOS)
76-
let linkCoreUI = envEnable("OPENSWIFTUI_LINK_COREUI", default: false)
76+
let linkCoreUI = envEnable("OPENSWIFTUI_LINK_COREUI", default: true)
7777
#else
7878
let linkCoreUI = envEnable("OPENSWIFTUI_LINK_COREUI")
7979
#endif
@@ -90,6 +90,14 @@ if linkCoreUI {
9090
)
9191
}
9292

93+
// MARK: - [env] OPENGSWIFTUI_SYMBOL_LOCATOR
94+
95+
#if os(macOS)
96+
let symbolLocatorCondition = envEnable("OPENGSWIFTUI_SYMBOL_LOCATOR", default: true)
97+
#else
98+
let symbolLocatorCondition = envEnable("OPENGSWIFTUI_SYMBOL_LOCATOR")
99+
#endif
100+
93101
// MARK: - [env] OPENGSWIFTUI_SWIFTUI_RENDER
94102

95103
#if os(macOS)
@@ -110,7 +118,7 @@ let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcode
110118
if warningsAsErrorsCondition {
111119
// Hold off the werror feature as we can't avoid the concurrency warning.
112120
// Reenable the folllowing after swift-evolution#443 is release.
113-
121+
114122
// sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"]))
115123
// sharedSwiftSettings.append(.unsafeFlags(["-Wwarning", "concurrency"]))
116124
}
@@ -168,7 +176,9 @@ let openSwiftUICoreTarget = Target.target(
168176
"CoreGraphicsShims",
169177
.product(name: "OpenGraphShims", package: "OpenGraph"),
170178
.product(name: "OpenBoxShims", package: "OpenBox"),
171-
] + (swiftUIRenderCondition ? ["OpenSwiftUISymbolDualTestsSupport"] : []),
179+
] + (swiftUIRenderCondition && symbolLocatorCondition ? ["OpenSwiftUISymbolDualTestsSupport"] : []),
180+
cSettings: sharedCSettings,
181+
cxxSettings: sharedCxxSettings,
172182
swiftSettings: sharedSwiftSettings
173183
)
174184

@@ -181,6 +191,8 @@ let openSwiftUICoreTestTarget = Target.testTarget(
181191
.product(name: "Numerics", package: "swift-numerics"),
182192
],
183193
exclude: ["README.md"],
194+
cSettings: sharedCSettings,
195+
cxxSettings: sharedCxxSettings,
184196
swiftSettings: sharedSwiftSettings
185197
)
186198

@@ -192,7 +204,8 @@ let cOpenSwiftUITarget = Target.target(
192204
cSettings: sharedCSettings + [
193205
.headerSearchPath("../OpenSwiftUI_SPI"),
194206
],
195-
cxxSettings: sharedCxxSettings
207+
cxxSettings: sharedCxxSettings,
208+
swiftSettings: sharedSwiftSettings
196209
)
197210

198211
let openSwiftUITarget = Target.target(
@@ -205,6 +218,8 @@ let openSwiftUITarget = Target.target(
205218
.product(name: "OpenGraphShims", package: "OpenGraph"),
206219
.product(name: "OpenBoxShims", package: "OpenBox"),
207220
],
221+
cSettings: sharedCSettings,
222+
cxxSettings: sharedCxxSettings,
208223
swiftSettings: sharedSwiftSettings
209224
)
210225

@@ -221,6 +236,8 @@ let openSwiftUIExtensionTarget = Target.target(
221236
dependencies: [
222237
"OpenSwiftUI",
223238
],
239+
cSettings: sharedCSettings,
240+
cxxSettings: sharedCxxSettings,
224241
swiftSettings: sharedSwiftSettings
225242
)
226243

@@ -231,6 +248,8 @@ let openSwiftUITestTarget = Target.testTarget(
231248
"OpenSwiftUITestsSupport",
232249
],
233250
exclude: ["README.md"],
251+
cSettings: sharedCSettings,
252+
cxxSettings: sharedCxxSettings,
234253
swiftSettings: sharedSwiftSettings
235254
)
236255

@@ -241,6 +260,8 @@ let openSwiftUICompatibilityTestTarget = Target.testTarget(
241260
.product(name: "Numerics", package: "swift-numerics"),
242261
],
243262
exclude: ["README.md"],
263+
cSettings: sharedCSettings,
264+
cxxSettings: sharedCxxSettings,
244265
swiftSettings: sharedSwiftSettings
245266
)
246267

@@ -256,6 +277,8 @@ let openSwiftUIBridgeTarget = Target.target(
256277
"OpenSwiftUI",
257278
],
258279
sources: ["Bridgeable.swift", bridgeFramework],
280+
cSettings: sharedCSettings,
281+
cxxSettings: sharedCxxSettings,
259282
swiftSettings: sharedSwiftSettings
260283
)
261284

@@ -267,6 +290,8 @@ let openSwiftUIBridgeTestTarget = Target.testTarget(
267290
],
268291
exclude: ["README.md"],
269292
sources: ["BridgeableTests.swift", bridgeFramework],
293+
cSettings: sharedCSettings,
294+
cxxSettings: sharedCxxSettings,
270295
swiftSettings: sharedSwiftSettings
271296
)
272297

@@ -281,7 +306,8 @@ let openSwiftUISymbolDualTestsSupportTarget = Target.target(
281306
cSettings: sharedCSettings + [
282307
.headerSearchPath("../OpenSwiftUI_SPI"),
283308
],
284-
cxxSettings: sharedCxxSettings
309+
cxxSettings: sharedCxxSettings,
310+
swiftSettings: sharedSwiftSettings
285311
)
286312

287313
let openSwiftUISymbolDualTestsTarget = Target.testTarget(
@@ -292,6 +318,8 @@ let openSwiftUISymbolDualTestsTarget = Target.testTarget(
292318
"OpenSwiftUISymbolDualTestsSupport",
293319
],
294320
exclude: ["README.md"],
321+
cSettings: sharedCSettings,
322+
cxxSettings: sharedCxxSettings,
295323
swiftSettings: sharedSwiftSettings
296324
)
297325

@@ -324,8 +352,7 @@ let package = Package(
324352
name: "OpenSwiftUI",
325353
products: products,
326354
dependencies: [
327-
.package(url: "https://github.com/apple/swift-numerics.git", from: "1.0.2"),
328-
.package(url: "https://github.com/OpenSwiftUIProject/SymbolLocator.git", from: "0.1.0"),
355+
.package(url: "https://github.com/apple/swift-numerics.git", from: "1.0.3"),
329356
],
330357
targets: [
331358
// TODO: Add SwiftGTK as an backend alternative for UIKit/AppKit on Linux and macOS
@@ -357,9 +384,6 @@ let package = Package(
357384

358385
openSwiftUIBridgeTarget,
359386
openSwiftUIBridgeTestTarget,
360-
361-
openSwiftUISymbolDualTestsSupportTarget,
362-
openSwiftUISymbolDualTestsTarget
363387
]
364388
)
365389

@@ -372,7 +396,7 @@ extension Target {
372396
swiftSettings.append(.define("OPENGRAPH_ATTRIBUTEGRAPH"))
373397
self.swiftSettings = swiftSettings
374398
}
375-
399+
376400
func addRBSettings() {
377401
// FIXME: Weird SwiftPM behavior for test Target. Otherwize we'll get the following error message
378402
// "could not determine executable path for bundle 'RenderBox.framework'"
@@ -401,7 +425,7 @@ extension Target {
401425
swiftSettings.append(.define("OPENSWIFTUI_SWIFT_LOG"))
402426
self.swiftSettings = swiftSettings
403427
}
404-
428+
405429
func addSwiftCryptoSettings() {
406430
dependencies.append(.product(name: "Crypto", package: "swift-crypto"))
407431
var swiftSettings = swiftSettings ?? []
@@ -421,7 +445,7 @@ let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH")
421445
if attributeGraphCondition {
422446
openSwiftUICoreTarget.addAGSettings()
423447
openSwiftUITarget.addAGSettings()
424-
448+
425449
openSwiftUISPITestTarget.addAGSettings()
426450
openSwiftUICoreTestTarget.addAGSettings()
427451
openSwiftUITestTarget.addAGSettings()
@@ -438,7 +462,7 @@ let renderBoxCondition = envEnable("OPENBOX_RENDERBOX")
438462
if renderBoxCondition {
439463
openSwiftUICoreTarget.addRBSettings()
440464
openSwiftUITarget.addRBSettings()
441-
465+
442466
openSwiftUISPITestTarget.addRBSettings()
443467
openSwiftUICoreTestTarget.addRBSettings()
444468
openSwiftUITestTarget.addRBSettings()
@@ -528,6 +552,19 @@ if compatibilityTestCondition {
528552
openSwiftUICompatibilityTestTarget.dependencies.append("OpenSwiftUI")
529553
}
530554

555+
// MARK: - SymbolLocator
556+
557+
if symbolLocatorCondition {
558+
package.dependencies.append(
559+
.package(url: "https://github.com/OpenSwiftUIProject/SymbolLocator.git", from: "0.2.0")
560+
)
561+
562+
package.targets += [
563+
openSwiftUISymbolDualTestsSupportTarget,
564+
openSwiftUISymbolDualTestsTarget,
565+
]
566+
}
567+
531568
extension [Platform] {
532569
static var darwinPlatforms: [Platform] {
533570
[.macOS, .iOS, .macCatalyst, .tvOS, .watchOS, .visionOS]

Sources/OpenSwiftUICore/Graphic/Color/CUIDesignLibraryCacheKey.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
// ID: EBD1C829A869D5EC3C2FDA55F4467D9A (SwiftUICore?)
88

99
#if canImport(Darwin) && OPENSWIFTUI_LINK_COREUI
10-
package import OpenSwiftUI_SPI
10+
import OpenSwiftUI_SPI
11+
package import CoreUI
1112

1213
package struct CUIDesignLibraryCacheKey: Hashable {
1314
package struct Entry: Hashable {

Sources/OpenSwiftUICore/Graphic/Color/DisplayGamut.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
// Audited for iOS 18.0
66
// Status: Complete
77

8+
#if canImport(Darwin) && OPENSWIFTUI_LINK_COREUI
89
import OpenSwiftUI_SPI
10+
import CoreUI
11+
#endif
912

1013
@_spi(Private)
1114
public enum DisplayGamut: Int {

Sources/OpenSwiftUICore/Graphic/Color/SystemColors.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// ID: 9E3352CE4697DF56A738786E16992848 (SwiftUICore)
88

99
import OpenSwiftUI_SPI
10+
#if canImport(Darwin) && OPENSWIFTUI_LINK_COREUI
11+
import CoreUI
12+
#endif
1013

1114
// MARK: - Color + SystemColorType
1215

Sources/OpenSwiftUI_SPI/Overlay/CoreUI/CUIDefaultDisplayGamut.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
#include "OpenSwiftUIBase.h"
1212

13-
#if OPENSWIFTUI_TARGET_OS_DARWIN && OPENSWIFTUI_LINK_COREUI
13+
#if OPENSWIFTUI_LINK_COREUI && OPENSWIFTUI_LINK_COREUI
1414

15-
@import CoreUI;
15+
#include <CoreUI/CUIDisplayGamut.h>
1616

17+
OPENSWIFTUI_EXPORT
1718
CUIDisplayGamut _CUIDefaultDisplayGamut();
1819

1920
#endif /* OPENSWIFTUI_TARGET_OS_DARWIN && OPENSWIFTUI_LINK_COREUI */

0 commit comments

Comments
 (0)