diff --git a/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift b/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift index 074ec81c..abeb0030 100644 --- a/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift +++ b/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift @@ -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 } } diff --git a/Sources/MarkdownUI/Utility/Color+RGBA.swift b/Sources/MarkdownUI/Utility/Color+RGBA.swift index 58d55a8d..583e9a4c 100644 --- a/Sources/MarkdownUI/Utility/Color+RGBA.swift +++ b/Sources/MarkdownUI/Utility/Color+RGBA.swift @@ -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( @@ -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 } }