From ecb2403ad24dbad9597b3fb2541579027ce9b04d Mon Sep 17 00:00:00 2001 From: Seyed Mojtaba Hosseini Zeidabadi Date: Tue, 10 Oct 2023 23:44:26 +0330 Subject: [PATCH 1/2] refactor: prefer checking module availability over the os check for `AssetImageProvider` --- Sources/MarkdownUI/Extensibility/AssetImageProvider.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift b/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift index a88387c4..074ec81c 100644 --- a/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift +++ b/Sources/MarkdownUI/Extensibility/AssetImageProvider.swift @@ -38,7 +38,7 @@ public struct AssetImageProvider: ImageProvider { } private func image(url: URL) -> PlatformImage? { - #if os(macOS) + #if canImport(AppKit) if let bundle, bundle != .main { return bundle.image(forResource: self.name(url)) } else { @@ -61,7 +61,7 @@ extension ImageProvider where Self == AssetImageProvider { #if canImport(UIKit) private typealias PlatformImage = UIImage -#elseif os(macOS) +#elseif canImport(AppKit) private typealias PlatformImage = NSImage #endif @@ -69,7 +69,7 @@ extension Image { fileprivate init(platformImage: PlatformImage) { #if canImport(UIKit) self.init(uiImage: platformImage) - #elseif os(macOS) + #elseif canImport(AppKit) self.init(nsImage: platformImage) #endif } From ee990ee45605f4896df6df73463ea17dd4b196b8 Mon Sep 17 00:00:00 2001 From: Seyed Mojtaba Hosseini Zeidabadi Date: Tue, 10 Oct 2023 23:46:36 +0330 Subject: [PATCH 2/2] refactor: prefer checking module availability over the os check for `Color+RGBA` --- Sources/MarkdownUI/Utility/Color+RGBA.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MarkdownUI/Utility/Color+RGBA.swift b/Sources/MarkdownUI/Utility/Color+RGBA.swift index 576041ab..58d55a8d 100644 --- a/Sources/MarkdownUI/Utility/Color+RGBA.swift +++ b/Sources/MarkdownUI/Utility/Color+RGBA.swift @@ -17,7 +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 os(macOS) + #if canImport(AppKit) self.init( nsColor: .init(name: nil) { appearance in if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {