From e1436a212c27051f8ab89cd16775950c892e6e9a Mon Sep 17 00:00:00 2001 From: Mathias Poimer Date: Fri, 4 Aug 2023 13:43:27 +0200 Subject: [PATCH 1/3] Removed default parameter value in (Navigation)Coordinator --- Sources/Toolbox/Coordinators/Coordinator.swift | 4 ++-- Sources/Toolbox/Coordinators/NavigationCoordinator.swift | 6 +++--- Tests/ToolboxTests/NavigationCoordinatorTests.swift | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/Toolbox/Coordinators/Coordinator.swift b/Sources/Toolbox/Coordinators/Coordinator.swift index 28a3fcc..5b6f017 100644 --- a/Sources/Toolbox/Coordinators/Coordinator.swift +++ b/Sources/Toolbox/Coordinators/Coordinator.swift @@ -13,8 +13,8 @@ open class Coordinator: NSObject { public let rootViewController: UIViewController var isPresented: Bool = false - public init(rootViewController: UIViewController? = nil) { - self.rootViewController = rootViewController ?? UIViewController() + public init(rootViewController: UIViewController) { + self.rootViewController = rootViewController super.init() } diff --git a/Sources/Toolbox/Coordinators/NavigationCoordinator.swift b/Sources/Toolbox/Coordinators/NavigationCoordinator.swift index 8f2288c..95b5e58 100644 --- a/Sources/Toolbox/Coordinators/NavigationCoordinator.swift +++ b/Sources/Toolbox/Coordinators/NavigationCoordinator.swift @@ -11,11 +11,11 @@ open class NavigationCoordinator: Coordinator { return childCoordinators.first } - public init(navigationController: UINavigationController? = nil) { + public init(navigationController: UINavigationController) { self.pushedViewControllers = WeakArray([]) - self.navigationController = navigationController ?? UINavigationController() + self.navigationController = navigationController - super.init(rootViewController: self.navigationController) + super.init(rootViewController: navigationController) if self.navigationController.delegate == nil { self.navigationController.delegate = self diff --git a/Tests/ToolboxTests/NavigationCoordinatorTests.swift b/Tests/ToolboxTests/NavigationCoordinatorTests.swift index da15842..32d7293 100644 --- a/Tests/ToolboxTests/NavigationCoordinatorTests.swift +++ b/Tests/ToolboxTests/NavigationCoordinatorTests.swift @@ -8,7 +8,7 @@ final class NavigationCoordinatorTests: XCTestCase { // Switch to the main actor context. await MainActor.run { - let navCoordinator = NavigationCoordinator() + let navCoordinator = NavigationCoordinator(navigationController: .init()) // Test your coordinator instance here, e.g.: XCTAssertNotNil(navCoordinator) @@ -26,7 +26,7 @@ final class NavigationCoordinatorTests: XCTestCase { // Switch to the main actor context. await MainActor.run { - let navCoordinator = NavigationCoordinator() + let navCoordinator = NavigationCoordinator(navigationController: .init()) // Test your coordinator instance here, e.g.: XCTAssertNotNil(navCoordinator) From 26e0a73aa60cfeff5f007a2c420babd8c4d318a2 Mon Sep 17 00:00:00 2001 From: Mathias Poimer Date: Mon, 7 Aug 2023 09:22:31 +0200 Subject: [PATCH 2/3] bumped min macOS to 11, fixed tests --- Package.swift | 2 +- .../NavigationCoordinatorTests.swift | 22 ++++--------------- .../ToolboxTests/TabBarCoordinatorTests.swift | 22 ++++--------------- Tests/ToolboxTests/UIColorTests.swift | 4 ++++ 4 files changed, 13 insertions(+), 37 deletions(-) diff --git a/Package.swift b/Package.swift index 47609e8..beb18ca 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ let package = Package( name: "Toolbox", platforms: [ .iOS(.v14), - .macOS(.v10_15) + .macOS(.v11) ], products: [ .library( diff --git a/Tests/ToolboxTests/NavigationCoordinatorTests.swift b/Tests/ToolboxTests/NavigationCoordinatorTests.swift index 32d7293..84dbe80 100644 --- a/Tests/ToolboxTests/NavigationCoordinatorTests.swift +++ b/Tests/ToolboxTests/NavigationCoordinatorTests.swift @@ -1,25 +1,9 @@ +#if canImport(UIKit) + @testable import Toolbox import XCTest final class NavigationCoordinatorTests: XCTestCase { - - func testNavigationCoordinatorInitialization() async throws { - let expectation = XCTestExpectation(description: "NavigationCoordinator initialization") - - // Switch to the main actor context. - await MainActor.run { - let navCoordinator = NavigationCoordinator(navigationController: .init()) - - // Test your coordinator instance here, e.g.: - XCTAssertNotNil(navCoordinator) - - // Fulfill the expectation when the test is complete. - expectation.fulfill() - } - - // Wait for the expectation to be fulfilled. - await fulfillment(of: [expectation], timeout: 10) - } func testNavigationCoordinatorRootIsUINavigationController() async throws { let expectation = XCTestExpectation(description: "NavigationCoordinator initialization") @@ -43,3 +27,5 @@ final class NavigationCoordinatorTests: XCTestCase { } } + +#endif diff --git a/Tests/ToolboxTests/TabBarCoordinatorTests.swift b/Tests/ToolboxTests/TabBarCoordinatorTests.swift index 1fa89e7..c415c36 100644 --- a/Tests/ToolboxTests/TabBarCoordinatorTests.swift +++ b/Tests/ToolboxTests/TabBarCoordinatorTests.swift @@ -1,25 +1,9 @@ +#if canImport(UIKit) + @testable import Toolbox import XCTest final class TabBarCoordinatorTests: XCTestCase { - - func testTabBarCoordinatorInitialization() async throws { - let expectation = XCTestExpectation(description: "TabBarCoordinator initialization") - - // Switch to the main actor context. - await MainActor.run { - let mainCoordinator = TabBarCoordinator() - - // Test your coordinator instance here, e.g.: - XCTAssertNotNil(mainCoordinator) - - // Fulfill the expectation when the test is complete. - expectation.fulfill() - } - - // Wait for the expectation to be fulfilled. - await fulfillment(of: [expectation], timeout: 10) - } func testTabBarCoordinatorRootIsUITabBarController() async throws { let expectation = XCTestExpectation(description: "TabBarCoordinator initialization") @@ -42,3 +26,5 @@ final class TabBarCoordinatorTests: XCTestCase { await fulfillment(of: [expectation], timeout: 10) } } + +#endif diff --git a/Tests/ToolboxTests/UIColorTests.swift b/Tests/ToolboxTests/UIColorTests.swift index def3ef8..204dad6 100644 --- a/Tests/ToolboxTests/UIColorTests.swift +++ b/Tests/ToolboxTests/UIColorTests.swift @@ -1,3 +1,5 @@ +#if canImport(UIKit) + import UIKit @testable import Toolbox import XCTest @@ -64,3 +66,5 @@ final class UIColorTests: XCTestCase { XCTAssertEqual(color.toHexString().uppercased(), "#ABCDEF") } } + +#endif From 80ea7a647674966bdade959c63972847dac8a5be Mon Sep 17 00:00:00 2001 From: Mathias Poimer <67694170+mpoimer@users.noreply.github.com> Date: Mon, 7 Aug 2023 09:46:07 +0200 Subject: [PATCH 3/3] Update master.yml updated step to use macOS 13 --- .github/workflows/master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 66ce43d..3b57e5c 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -9,7 +9,7 @@ on: jobs: test: name: Run unit tests - runs-on: macOS-latest + runs-on: macOS-13 steps: - name: Checkout repository uses: actions/checkout@v1