Skip to content

Commit 8f6affc

Browse files
authored
fix macCatalyst build failure: re-order #if canImport(UIKit) (#283)
by placing `#if canImport(UIKit)` first, it means that building for `#if targetEnvironment(macCatalyst)` doesn't fail attempting to use and link in `AppKit` things (since `macCatalyst` apps can link both `UIKit` and `AppKit`
1 parent 2443543 commit 8f6affc

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Sources/MarkdownUI/Extensibility/AssetImageProvider.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public struct AssetImageProvider: ImageProvider {
3838
}
3939

4040
private func image(url: URL) -> PlatformImage? {
41-
#if canImport(AppKit)
41+
#if canImport(UIKit)
42+
return UIImage(named: self.name(url), in: self.bundle, with: nil)
43+
#elseif canImport(AppKit)
4244
if let bundle, bundle != .main {
4345
return bundle.image(forResource: self.name(url))
4446
} else {
4547
return NSImage(named: self.name(url))
4648
}
47-
#elseif canImport(UIKit)
48-
return UIImage(named: self.name(url), in: self.bundle, with: nil)
4949
#endif
5050
}
5151
}

Sources/MarkdownUI/Utility/Color+RGBA.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,7 @@ extension Color {
1717
/// - light: The light appearance color value.
1818
/// - dark: The dark appearance color value.
1919
public init(light: @escaping @autoclosure () -> Color, dark: @escaping @autoclosure () -> Color) {
20-
#if canImport(AppKit)
21-
self.init(
22-
nsColor: .init(name: nil) { appearance in
23-
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {
24-
return NSColor(light())
25-
} else {
26-
return NSColor(dark())
27-
}
28-
}
29-
)
30-
#elseif os(watchOS)
20+
#if os(watchOS)
3121
self = dark()
3222
#elseif canImport(UIKit)
3323
self.init(
@@ -42,6 +32,16 @@ extension Color {
4232
}
4333
}
4434
)
35+
#elseif canImport(AppKit)
36+
self.init(
37+
nsColor: .init(name: nil) { appearance in
38+
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {
39+
return NSColor(light())
40+
} else {
41+
return NSColor(dark())
42+
}
43+
}
44+
)
4545
#endif
4646
}
4747
}

0 commit comments

Comments
 (0)