Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: prefer checking module availability over the os check #268

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/MarkdownUI/Extensibility/AssetImageProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -61,15 +61,15 @@ extension ImageProvider where Self == AssetImageProvider {

#if canImport(UIKit)
private typealias PlatformImage = UIImage
#elseif os(macOS)
#elseif canImport(AppKit)
private typealias PlatformImage = NSImage
#endif

extension Image {
fileprivate init(platformImage: PlatformImage) {
#if canImport(UIKit)
self.init(uiImage: platformImage)
#elseif os(macOS)
#elseif canImport(AppKit)
self.init(nsImage: platformImage)
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/MarkdownUI/Utility/Color+RGBA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading