From a0374ef136edce16520bce883b35edba47c14eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=CC=81s=CC=8C=20Valenta?= Date: Sun, 6 Jul 2025 15:23:13 +0200 Subject: [PATCH 1/2] Swift 6.2 --- Package.resolved | 61 +++++++++++++++---------------- Sources/FlowPilot/AnyRouter.swift | 6 +-- Sources/FlowPilot/Router.swift | 9 ++++- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/Package.resolved b/Package.resolved index 57d0bbb..bae8633 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,34 +1,33 @@ { - "object": { - "pins": [ - { - "package": "CleevioCore", - "repositoryURL": "https://github.com/cleevio/CleevioCore.git", - "state": { - "branch": null, - "revision": "593b5d1011ad0aa6963ea2d8bf2ddc5e59caa917", - "version": "2.1.7" - } - }, - { - "package": "FloatingPanel", - "repositoryURL": "https://github.com/scenee/FloatingPanel", - "state": { - "branch": null, - "revision": "2a29cb5b3ecf4beb67cf524a030dd74a11b956c4", - "version": "2.6.1" - } - }, - { - "package": "swift-collections", - "repositoryURL": "https://github.com/apple/swift-collections", - "state": { - "branch": null, - "revision": "937e904258d22af6e447a0b72c0bc67583ef64a2", - "version": "1.0.4" - } + "originHash" : "1d3d706e27c94b84b27fc9f9106ad443dab9dbebc0bb0f94efe495f1553857ad", + "pins" : [ + { + "identity" : "cleeviocore", + "kind" : "remoteSourceControl", + "location" : "https://github.com/cleevio/CleevioCore.git", + "state" : { + "revision" : "593b5d1011ad0aa6963ea2d8bf2ddc5e59caa917", + "version" : "2.1.7" } - ] - }, - "version": 1 + }, + { + "identity" : "floatingpanel", + "kind" : "remoteSourceControl", + "location" : "https://github.com/scenee/FloatingPanel", + "state" : { + "revision" : "1d2e3a0304d5d56bae7d0c0bb861921374390bb0", + "version" : "2.8.8" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections", + "state" : { + "revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2", + "version" : "1.0.4" + } + } + ], + "version" : 3 } diff --git a/Sources/FlowPilot/AnyRouter.swift b/Sources/FlowPilot/AnyRouter.swift index 67d3927..17537bb 100644 --- a/Sources/FlowPilot/AnyRouter.swift +++ b/Sources/FlowPilot/AnyRouter.swift @@ -36,9 +36,9 @@ final public class AnyRouter: Router { - Note: Both `presentAction` and `dismissAction` closures are stored as properties to be used later when presenting or dismissing a view controller. The closures should take into account the platform-specific APIs when performing their respective actions. */ @inlinable - init(presentAction: @escaping (PlatformViewController, Bool) -> Void, - dismissAction: @escaping (Bool, (() -> Void)?) -> Void, - dismissRouterAction: @escaping (Bool, (() -> Void)?) -> Void) { + init(presentAction: @escaping @MainActor (PlatformViewController, Bool) -> Void, + dismissAction: @escaping @MainActor (Bool, (() -> Void)?) -> Void, + dismissRouterAction: @escaping @MainActor (Bool, (() -> Void)?) -> Void) { self.presentAction = presentAction self.dismissAction = dismissAction self.dismissRouterAction = dismissRouterAction diff --git a/Sources/FlowPilot/Router.swift b/Sources/FlowPilot/Router.swift index db35920..663d50e 100644 --- a/Sources/FlowPilot/Router.swift +++ b/Sources/FlowPilot/Router.swift @@ -10,6 +10,7 @@ import Combine /// A protocol that defines the common behavior of a router that can present and dismiss view controllers. @available(macOS 10.15, *) +@MainActor public protocol Router: AnyObject { /// Presents a view controller. /// @@ -53,7 +54,13 @@ public extension Router { @inlinable @MainActor func eraseToAnyRouter() -> AnyRouter { - AnyRouter(presentAction: present(_:animated:), dismissAction: dismiss(animated:completion:), dismissRouterAction: dismissRouter(animated:completion:)) + AnyRouter(presentAction: { viewController, animated in + self.present(viewController, animated: animated) + }, dismissAction: { animated, completion in + self.dismiss(animated: animated, completion: completion) + }, dismissRouterAction: { animated, completion in + self.dismissRouter(animated: animated, completion: completion) + }) } } From 2e585c759518032df24297d88ebecdff2164d693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Valenta?= Date: Mon, 14 Jul 2025 15:33:19 +0200 Subject: [PATCH 2/2] Updated Example project to Swift6 compilation mode --- Example/FlowPilotExample.xcodeproj/project.pbxproj | 4 ++-- Example/Sources/Scenes/Root/First/FirstViewModel.swift | 5 +++-- .../ResponseParameters/ResponseParametersViewModel.swift | 7 ++++--- Example/Sources/Scenes/Root/RootViewModel.swift | 2 +- Example/Sources/Scenes/Root/Second/SecondViewModel.swift | 3 ++- .../Scenes/Root/ThirdModal/ThirdModalViewModel.swift | 3 ++- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Example/FlowPilotExample.xcodeproj/project.pbxproj b/Example/FlowPilotExample.xcodeproj/project.pbxproj index efd00fa..c19d27c 100644 --- a/Example/FlowPilotExample.xcodeproj/project.pbxproj +++ b/Example/FlowPilotExample.xcodeproj/project.pbxproj @@ -297,7 +297,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -329,7 +329,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Example/Sources/Scenes/Root/First/FirstViewModel.swift b/Example/Sources/Scenes/Root/First/FirstViewModel.swift index 24c6eea..b1a363b 100644 --- a/Example/Sources/Scenes/Root/First/FirstViewModel.swift +++ b/Example/Sources/Scenes/Root/First/FirstViewModel.swift @@ -8,12 +8,13 @@ import Foundation import Combine -protocol FirstViewModelRoutingDelegate: AnyObject { - func dismiss() +protocol FirstViewModelRoutingDelegate: AnyObject, Sendable { + @MainActor func dismiss() func continueLoop() async throws func showSecondView() async throws } +@MainActor final class FirstViewModel: ObservableObject { var count: Int diff --git a/Example/Sources/Scenes/Root/ResponseParameters/ResponseParametersViewModel.swift b/Example/Sources/Scenes/Root/ResponseParameters/ResponseParametersViewModel.swift index 0124cc5..788381b 100644 --- a/Example/Sources/Scenes/Root/ResponseParameters/ResponseParametersViewModel.swift +++ b/Example/Sources/Scenes/Root/ResponseParameters/ResponseParametersViewModel.swift @@ -8,10 +8,11 @@ import Foundation import Combine -protocol ResponseParametersViewModelRoutingDelegate: AnyObject { - func response(with: Bool) +protocol ResponseParametersViewModelRoutingDelegate: AnyObject, Sendable { + @MainActor func response(with: Bool) } +@MainActor final class ResponseParametersViewModel: ObservableObject { weak var routingDelegate: ResponseParametersViewModelRoutingDelegate? @@ -28,7 +29,7 @@ final class ResponseParametersViewModel: ObservableObject { func send(action: Action) async { switch action { case .save: - await routingDelegate?.response(with: value) + routingDelegate?.response(with: value) } } } diff --git a/Example/Sources/Scenes/Root/RootViewModel.swift b/Example/Sources/Scenes/Root/RootViewModel.swift index f85da4e..c4c412b 100644 --- a/Example/Sources/Scenes/Root/RootViewModel.swift +++ b/Example/Sources/Scenes/Root/RootViewModel.swift @@ -8,7 +8,7 @@ import Foundation import Combine -protocol RootViewModelRoutingDelegate: AnyObject { +protocol RootViewModelRoutingDelegate: AnyObject, Sendable { func showFirst() async throws func showSecondView() async throws func showThirdModal() async throws diff --git a/Example/Sources/Scenes/Root/Second/SecondViewModel.swift b/Example/Sources/Scenes/Root/Second/SecondViewModel.swift index 87fd4aa..1dbdd44 100644 --- a/Example/Sources/Scenes/Root/Second/SecondViewModel.swift +++ b/Example/Sources/Scenes/Root/Second/SecondViewModel.swift @@ -8,10 +8,11 @@ import Foundation import Combine -protocol SecondViewModelRoutingDelegate: AnyObject { +protocol SecondViewModelRoutingDelegate: AnyObject, Sendable { func dismiss() async } +@MainActor final class SecondViewModel: ObservableObject { weak var routingDelegate: SecondViewModelRoutingDelegate? diff --git a/Example/Sources/Scenes/Root/ThirdModal/ThirdModalViewModel.swift b/Example/Sources/Scenes/Root/ThirdModal/ThirdModalViewModel.swift index e956b2d..f6c2fb0 100644 --- a/Example/Sources/Scenes/Root/ThirdModal/ThirdModalViewModel.swift +++ b/Example/Sources/Scenes/Root/ThirdModal/ThirdModalViewModel.swift @@ -8,10 +8,11 @@ import Foundation import Combine -protocol ThirdModalViewModelRoutingDelegate: AnyObject { +protocol ThirdModalViewModelRoutingDelegate: AnyObject, Sendable { func dismiss() async } +@MainActor final class ThirdModalViewModel: ObservableObject { weak var routingDelegate: ThirdModalViewModelRoutingDelegate?