From 7aacf8082e49531df42e457dcb26d9ba60d26f6c Mon Sep 17 00:00:00 2001 From: Mykyta Konopelko Date: Mon, 30 Sep 2024 19:30:25 +0200 Subject: [PATCH] fix Swift 5.8 + ImageResource --- Source/CrossPlatform.swift | 18 +++++++++--------- Source/ImagePlaceholder.swift | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/CrossPlatform.swift b/Source/CrossPlatform.swift index 67875dc..9737f3e 100644 --- a/Source/CrossPlatform.swift +++ b/Source/CrossPlatform.swift @@ -40,44 +40,44 @@ public protocol ImageView: AnyObject { #if os(iOS) || os(tvOS) private enum Screen { -#if swift(>=6.0) + #if swift(>=6.0) @MainActor static var scale: CGFloat { return UIScreen.main.scale } -#else + #else static var scale: CGFloat { return UIScreen.main.scale } -#endif + #endif } #elseif os(watchOS) import WatchKit private enum Screen { -#if swift(>=6.0) + #if swift(>=6.0) @MainActor static var scale: CGFloat { return WKInterfaceDevice.current().screenScale } -#else + #else static var scale: CGFloat { return WKInterfaceDevice.current().screenScale } -#endif + #endif } #elseif supportsVisionOS public enum Screen { // visionOS doesn't have a screen scale, so we'll just use 2x for Tests. // override it on your own risk. -#if swift(>=6.0) + #if swift(>=6.0) @MainActor public static var scale: CGFloat? -#else + #else public static var scale: CGFloat? -#endif + #endif } #endif diff --git a/Source/ImagePlaceholder.swift b/Source/ImagePlaceholder.swift index 6e7c83e..f0a18e9 100644 --- a/Source/ImagePlaceholder.swift +++ b/Source/ImagePlaceholder.swift @@ -31,7 +31,7 @@ public enum ImagePlaceholder { case imageNamed(String) #endif - #if os(iOS) || os(tvOS) || supportsVisionOS + #if swift(>=5.9) && (os(iOS) || os(tvOS) || supportsVisionOS) @available(iOS 17.0, macOS 14.0, tvOS 17.0, *) func resource(_ res: ImageResource) -> Self { return .init(resource: res)