Skip to content

Commit 2443543

Browse files
authored
Prefer checking module availability over the os check (gonzalezreal#268)
* refactor: prefer checking module availability over the os check for `AssetImageProvider` * refactor: prefer checking module availability over the os check for `Color+RGBA`
1 parent e7b49f0 commit 2443543

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/MarkdownUI/Extensibility/AssetImageProvider.swift

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

4040
private func image(url: URL) -> PlatformImage? {
41-
#if os(macOS)
41+
#if canImport(AppKit)
4242
if let bundle, bundle != .main {
4343
return bundle.image(forResource: self.name(url))
4444
} else {
@@ -61,15 +61,15 @@ extension ImageProvider where Self == AssetImageProvider {
6161

6262
#if canImport(UIKit)
6363
private typealias PlatformImage = UIImage
64-
#elseif os(macOS)
64+
#elseif canImport(AppKit)
6565
private typealias PlatformImage = NSImage
6666
#endif
6767

6868
extension Image {
6969
fileprivate init(platformImage: PlatformImage) {
7070
#if canImport(UIKit)
7171
self.init(uiImage: platformImage)
72-
#elseif os(macOS)
72+
#elseif canImport(AppKit)
7373
self.init(nsImage: platformImage)
7474
#endif
7575
}

Sources/MarkdownUI/Utility/Color+RGBA.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +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 os(macOS)
20+
#if canImport(AppKit)
2121
self.init(
2222
nsColor: .init(name: nil) { appearance in
2323
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {

0 commit comments

Comments
 (0)