Răsfoiți Sursa

Add compiling condition for nonisolated

onevcat 1 an în urmă
părinte
comite
75b59fd72b
1 a modificat fișierele cu 16 adăugiri și 4 ștergeri
  1. 16 4
      Sources/Image/Image.swift

+ 16 - 4
Sources/Image/Image.swift

@@ -27,12 +27,10 @@
 
 #if os(macOS)
 import AppKit
-nonisolated(unsafe) private let imagesKey = malloc(1)!
-nonisolated(unsafe) private let durationKey = malloc(1)!
-#else
+#else // os(macOS)
 import UIKit
 import MobileCoreServices
-#endif
+#endif // os(macOS)
 
 #if !os(watchOS)
 import CoreImage
@@ -45,9 +43,23 @@ import ImageIO
 import UniformTypeIdentifiers
 #endif
 
+#if compiler(>=5.10)
 nonisolated(unsafe) private let animatedImageDataKey = malloc(1)!
 nonisolated(unsafe) private let imageFrameCountKey = malloc(1)!
 nonisolated(unsafe) private let imageSourceKey = malloc(1)!
+#if os(macOS)
+nonisolated(unsafe) private let imagesKey = malloc(1)!
+nonisolated(unsafe) private let durationKey = malloc(1)!
+#endif // os(macOS)
+#else // compiler(>=5.10)
+private let animatedImageDataKey = malloc(1)!
+private let imageFrameCountKey = malloc(1)!
+private let imageSourceKey = malloc(1)!
+#if os(macOS)
+private let imagesKey = malloc(1)!
+private let durationKey = malloc(1)!
+#endif os(macOS)
+#endif // compiler(>=5.10)
 
 // MARK: - Image Properties
 extension KingfisherWrapper where Base: KFCrossPlatformImage {