Skip to content

Commit

Permalink
fix macCatalyst build failure: re-order #if canImport(UIKit) (#283)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
kirkbig authored Dec 31, 2023
1 parent 2443543 commit 8f6affc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Sources/MarkdownUI/Extensibility/AssetImageProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public struct AssetImageProvider: ImageProvider {
}

private func image(url: URL) -> PlatformImage? {
#if canImport(AppKit)
#if canImport(UIKit)
return UIImage(named: self.name(url), in: self.bundle, with: nil)
#elseif canImport(AppKit)
if let bundle, bundle != .main {
return bundle.image(forResource: self.name(url))
} else {
return NSImage(named: self.name(url))
}
#elseif canImport(UIKit)
return UIImage(named: self.name(url), in: self.bundle, with: nil)
#endif
}
}
Expand Down
22 changes: 11 additions & 11 deletions Sources/MarkdownUI/Utility/Color+RGBA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ extension Color {
/// - light: The light appearance color value.
/// - dark: The dark appearance color value.
public init(light: @escaping @autoclosure () -> Color, dark: @escaping @autoclosure () -> Color) {
#if canImport(AppKit)
self.init(
nsColor: .init(name: nil) { appearance in
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {
return NSColor(light())
} else {
return NSColor(dark())
}
}
)
#elseif os(watchOS)
#if os(watchOS)
self = dark()
#elseif canImport(UIKit)
self.init(
Expand All @@ -42,6 +32,16 @@ extension Color {
}
}
)
#elseif canImport(AppKit)
self.init(
nsColor: .init(name: nil) { appearance in
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {
return NSColor(light())
} else {
return NSColor(dark())
}
}
)
#endif
}
}

0 comments on commit 8f6affc

Please sign in to comment.