Ver Fonte

Enable complete concurrency check for demo

onevcat há 1 ano atrás
pai
commit
0aee6806a5

+ 7 - 6
Demo/Demo/Kingfisher-Demo/Extensions/UIViewController+KingfisherOperation.swift

@@ -27,8 +27,8 @@
 import UIKit
 import Kingfisher
 
-protocol MainDataViewReloadable {
-    func reload()
+protocol MainDataViewReloadable: Sendable {
+    @MainActor func reload()
 }
 
 extension UITableViewController: MainDataViewReloadable {
@@ -44,25 +44,26 @@ extension UICollectionViewController: MainDataViewReloadable {
 }
 
 protocol KingfisherActionAlertPopup {
+    @MainActor
     func alertPopup(_ sender: Any) -> UIAlertController
 }
 
-func cleanCacheAction() -> UIAlertAction {
+@MainActor func cleanCacheAction() -> UIAlertAction {
     return UIAlertAction(title: "Clean Cache", style: .default) { _ in
         KingfisherManager.shared.cache.clearMemoryCache()
         KingfisherManager.shared.cache.clearDiskCache()
     }
 }
 
-func reloadAction(_ reloadable: MainDataViewReloadable) -> UIAlertAction {
+@MainActor func reloadAction(_ reloadable: MainDataViewReloadable) -> UIAlertAction {
     return UIAlertAction(title: "Reload", style: .default) { _ in
         reloadable.reload()
     }
 }
 
-let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
+@MainActor let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
 
-func createAlert(_ sender: Any, actions: [UIAlertAction]) -> UIAlertController {
+@MainActor func createAlert(_ sender: Any, actions: [UIAlertAction]) -> UIAlertController {
     let alert = UIAlertController(title: "Action", message: nil, preferredStyle: .actionSheet)
     alert.popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem
     alert.popoverPresentationController?.permittedArrowDirections = .any

+ 9 - 7
Demo/Demo/Kingfisher-Demo/ViewControllers/IndicatorCollectionViewController.swift

@@ -42,13 +42,15 @@ class IndicatorCollectionViewController: UICollectionViewController {
         func startAnimatingView() {
             view.isHidden = false
             timer = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: true) { _ in
-                UIView.animate(withDuration: 0.2, animations: {
-                    if self.view.backgroundColor == .red {
-                        self.view.backgroundColor = .orange
-                    } else {
-                        self.view.backgroundColor = .red
-                    }
-                })
+                Task { @MainActor in
+                    UIView.animate(withDuration: 0.2, animations: {
+                        if self.view.backgroundColor == .red {
+                            self.view.backgroundColor = .orange
+                        } else {
+                            self.view.backgroundColor = .red
+                        }
+                    })
+                }
             }
         }
         

+ 2 - 0
Demo/Kingfisher-Demo.xcodeproj/project.pbxproj

@@ -1027,6 +1027,7 @@
 				ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = iphoneos;
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+				SWIFT_STRICT_CONCURRENCY = complete;
 				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TVOS_DEPLOYMENT_TARGET = 13.0;
@@ -1084,6 +1085,7 @@
 				SDKROOT = iphoneos;
 				SWIFT_COMPILATION_MODE = wholemodule;
 				SWIFT_OPTIMIZATION_LEVEL = "-O";
+				SWIFT_STRICT_CONCURRENCY = complete;
 				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TVOS_DEPLOYMENT_TARGET = 13.0;