فهرست منبع

Allow complete concurrency check and build test

onevcat 1 سال پیش
والد
کامیت
1cb171c3ab

+ 3 - 1
Kingfisher.xcodeproj/project.pbxproj

@@ -1001,6 +1001,7 @@
 				SUPPORTED_PLATFORMS = "watchsimulator iphonesimulator appletvsimulator watchos appletvos iphoneos macosx";
 				SWIFT_INSTALL_OBJC_HEADER = NO;
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+				SWIFT_STRICT_CONCURRENCY = complete;
 				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2,3,4";
 				TVOS_DEPLOYMENT_TARGET = 13.0;
@@ -1061,6 +1062,7 @@
 				SWIFT_COMPILATION_MODE = wholemodule;
 				SWIFT_INSTALL_OBJC_HEADER = NO;
 				SWIFT_OPTIMIZATION_LEVEL = "-O";
+				SWIFT_STRICT_CONCURRENCY = complete;
 				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2,3,4";
 				TVOS_DEPLOYMENT_TARGET = 13.0;
@@ -1087,8 +1089,8 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
 				CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;
 				CURRENT_PROJECT_VERSION = 2700;
-				DEFINES_MODULE = YES;
 				DEAD_CODE_STRIPPING = YES;
+				DEFINES_MODULE = YES;
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_CURRENT_VERSION = 2700;
 				DYLIB_INSTALL_NAME_BASE = "@rpath";

+ 1 - 0
Sources/Extensions/ImageView+Kingfisher.swift

@@ -32,6 +32,7 @@ import AppKit
 import UIKit
 #endif
 
+@MainActor
 extension KingfisherWrapper where Base: KFCrossPlatformImageView {
 
     // MARK: Setting Image

+ 1 - 0
Sources/General/KF.swift

@@ -139,6 +139,7 @@ extension KF {
     }
 }
 
+@MainActor
 extension KF.Builder {
     #if !os(watchOS)
 

+ 2 - 0
Sources/SwiftUI/KFAnimatedImage.swift

@@ -84,6 +84,7 @@ public struct KFAnimatedImageViewRepresenter: KFCrossPlatformViewRepresentable,
     }
     #endif
     
+    @MainActor
     private func makeImageView() -> AnimatedImageView {
         let view = AnimatedImageView()
         
@@ -97,6 +98,7 @@ public struct KFAnimatedImageViewRepresenter: KFCrossPlatformViewRepresentable,
         return view
     }
     
+    @MainActor
     private func updateImageView(_ imageView: AnimatedImageView) {
         imageView.image = image
     }

+ 1 - 0
Sources/SwiftUI/KFImageProtocol.swift

@@ -43,6 +43,7 @@ public protocol KFImageProtocol: View, KFOptionSetter {
 
 @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
 extension KFImageProtocol {
+    @MainActor
     public var body: some View {
         ZStack {
             KFImageRenderer<HoldingView>(

+ 1 - 1
Sources/Utility/DisplayLink.swift

@@ -32,7 +32,7 @@ import AppKit
 import CoreVideo
 #endif
 
-protocol DisplayLinkCompatible: AnyObject {
+protocol DisplayLinkCompatible: AnyObject, Sendable {
     var isPaused: Bool { get set }
     
     var preferredFramesPerSecond: NSInteger { get }

+ 5 - 2
Sources/Views/AnimatedImageView.swift

@@ -75,6 +75,7 @@ let KFRunLoopModeCommon = RunLoop.Mode.common
 ///
 /// Kingfisher supports setting GIF animated data to either `UIImageView` or ``AnimatedImageView`` out of the box. So
 /// it would be fairly easy to switch between them.
+@MainActor
 open class AnimatedImageView: KFCrossPlatformImageView {
     /// Proxy object for preventing a reference cycle between the `CADDisplayLink` and `AnimatedImageView`.
     class TargetProxy {
@@ -84,7 +85,7 @@ open class AnimatedImageView: KFCrossPlatformImageView {
             self.target = target
         }
         
-        @objc func onScreenUpdate() {
+        @MainActor @objc func onScreenUpdate() {
             target?.updateFrameIfNeeded()
         }
     }
@@ -247,7 +248,9 @@ open class AnimatedImageView: KFCrossPlatformImageView {
     
     deinit {
         if isDisplayLinkInitialized {
-            displayLink.invalidate()
+            Task { @MainActor in
+                self.displayLink.invalidate()
+            }
         }
     }
     

+ 1 - 0
Tests/KingfisherTests/ImageViewExtensionTests.swift

@@ -27,6 +27,7 @@
 import XCTest
 @testable import Kingfisher
 
+@MainActor
 class ImageViewExtensionTests: XCTestCase {
 
     var imageView: KFCrossPlatformImageView!

+ 1 - 0
Tests/KingfisherTests/UIButtonExtensionTests.swift

@@ -29,6 +29,7 @@ import UIKit
 import XCTest
 @testable import Kingfisher
 
+@MainActor
 class UIButtonExtensionTests: XCTestCase {
 
     var button: UIButton!