Просмотр исходного кода

Fix building issue on Xcode 16

onevcat 1 год назад
Родитель
Сommit
97191c872e
3 измененных файлов с 15 добавлено и 4 удалено
  1. 4 0
      Sources/General/Kingfisher.swift
  2. 2 2
      Sources/Image/Image.swift
  3. 9 2
      Sources/Utility/DisplayLink.swift

+ 4 - 0
Sources/General/Kingfisher.swift

@@ -36,7 +36,11 @@ public typealias KFCrossPlatformImageView   = NSImageView
 public typealias KFCrossPlatformButton      = NSButton
 
 // `NSImage` is not yet Sendable. We have to assume it sendable to resolve warnings in Kingfisher.
+#if swift(>=6)
+extension KFCrossPlatformImage: @retroactive @unchecked Sendable { }
+#else
 extension KFCrossPlatformImage: @unchecked Sendable { }
+#endif // swift(>=6)
 #else // os(macOS)
 import UIKit
 public typealias KFCrossPlatformImage       = UIImage

+ 2 - 2
Sources/Image/Image.swift

@@ -27,8 +27,8 @@
 
 #if os(macOS)
 import AppKit
-private let imagesKey = malloc(1)!
-private let durationKey = malloc(1)!
+nonisolated(unsafe) private let imagesKey = malloc(1)!
+nonisolated(unsafe) private let durationKey = malloc(1)!
 #else
 import UIKit
 import MobileCoreServices

+ 9 - 2
Sources/Utility/DisplayLink.swift

@@ -75,10 +75,17 @@ extension NSView {
 
 #if swift(>=5.9)
 @available(macOS 14.0, *)
-extension CADisplayLink: DisplayLinkCompatible, @unchecked Sendable {
+extension CADisplayLink: DisplayLinkCompatible {
     var preferredFramesPerSecond: NSInteger { return 0 }
 }
-#endif
+#if swift(>=6)
+@available(macOS 14.0, *)
+extension CADisplayLink: @retroactive @unchecked Sendable { }
+#else // swift(>=6)
+@available(macOS 14.0, *)
+extension CADisplayLink: @unchecked Sendable { }
+#endif // swift(>=6)
+#endif // swift(>=5.9)
 
 final class DisplayLink: DisplayLinkCompatible, @unchecked Sendable {
     private var link: CVDisplayLink?