From 847c2afc447bec4e649c555b619fe2d78e6e9404 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 16:54:15 +0200 Subject: [PATCH] Flattened the folder structure of the Libraries now that the idea is to use precompiler processors to filter out platform-specific code. --- Sources/Communications/Classes/MockURLProtocol.swift | 2 ++ Sources/Communications/Use Cases/MakeURLRequestUseCase.swift | 2 ++ .../{Platform/Apple/iOS => }/Routers/BaseNavigationRouter.swift | 2 ++ .../Apple/iOS => }/Routers/ModalNavigationRouter.swift | 2 ++ .../{Platform/Apple/iOS => }/Routers/PushNavigationRouter.swift | 2 ++ .../{Platform/Apple/iOS => }/Routers/WindowRouter.swift | 2 ++ Sources/Persistence/Classes/Fetcher.swift | 2 ++ Sources/Persistence/Protocols/Service.swift | 2 ++ .../{ => Cases}/Use Cases/MakeURLRequestUseCaseTests.swift | 0 .../{Platform/iOS => Cases}/Protocols/CoordinatorTests.swift | 2 ++ .../{Platform/iOS => }/Helpers/TestCoordinators.swift | 2 ++ .../{ => Cases}/Property Wrappers/DependencyTests.swift | 0 .../{ => Cases}/Services/DependencyServiceTests.swift | 0 Tests/Persistence/{ => Cases}/Classes/FetcherTests.swift | 0 Tests/Persistence/{ => Cases}/Extensions/URL+DevicesTests.swift | 0 15 files changed, 20 insertions(+) rename Sources/Coordination/{Platform/Apple/iOS => }/Routers/BaseNavigationRouter.swift (99%) rename Sources/Coordination/{Platform/Apple/iOS => }/Routers/ModalNavigationRouter.swift (99%) rename Sources/Coordination/{Platform/Apple/iOS => }/Routers/PushNavigationRouter.swift (99%) rename Sources/Coordination/{Platform/Apple/iOS => }/Routers/WindowRouter.swift (98%) rename Tests/Communications/{ => Cases}/Use Cases/MakeURLRequestUseCaseTests.swift (100%) rename Tests/Coordination/{Platform/iOS => Cases}/Protocols/CoordinatorTests.swift (99%) rename Tests/Coordination/{Platform/iOS => }/Helpers/TestCoordinators.swift (98%) rename Tests/Dependencies/{ => Cases}/Property Wrappers/DependencyTests.swift (100%) rename Tests/Dependencies/{ => Cases}/Services/DependencyServiceTests.swift (100%) rename Tests/Persistence/{ => Cases}/Classes/FetcherTests.swift (100%) rename Tests/Persistence/{ => Cases}/Extensions/URL+DevicesTests.swift (100%) diff --git a/Sources/Communications/Classes/MockURLProtocol.swift b/Sources/Communications/Classes/MockURLProtocol.swift index 892f1dd..f4122a6 100644 --- a/Sources/Communications/Classes/MockURLProtocol.swift +++ b/Sources/Communications/Classes/MockURLProtocol.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) import Foundation /// This class overrides the `URLProtocol` protocol used by the `URLSession` to handle the loading of protocol-specific URL data so it is possible to mock URL response for testing purposes. @@ -116,3 +117,4 @@ public struct MockURLResponse { } } +#endif diff --git a/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift b/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift index 099fec1..f483f8a 100644 --- a/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift +++ b/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) import Foundation /// This use case generate a url request out of a given endpoint. @@ -55,3 +56,4 @@ public struct MakeURLRequestUseCase { } } +#endif diff --git a/Sources/Coordination/Platform/Apple/iOS/Routers/BaseNavigationRouter.swift b/Sources/Coordination/Routers/BaseNavigationRouter.swift similarity index 99% rename from Sources/Coordination/Platform/Apple/iOS/Routers/BaseNavigationRouter.swift rename to Sources/Coordination/Routers/BaseNavigationRouter.swift index dd437d1..7b0ba78 100644 --- a/Sources/Coordination/Platform/Apple/iOS/Routers/BaseNavigationRouter.swift +++ b/Sources/Coordination/Routers/BaseNavigationRouter.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if os(iOS) import UIKit /// This is a base class for the `NavigationRouter` concrete router implementations. @@ -70,3 +71,4 @@ extension BaseNavigationRouter: UINavigationControllerDelegate { } } +#endif diff --git a/Sources/Coordination/Platform/Apple/iOS/Routers/ModalNavigationRouter.swift b/Sources/Coordination/Routers/ModalNavigationRouter.swift similarity index 99% rename from Sources/Coordination/Platform/Apple/iOS/Routers/ModalNavigationRouter.swift rename to Sources/Coordination/Routers/ModalNavigationRouter.swift index 4f52159..b87fec5 100644 --- a/Sources/Coordination/Platform/Apple/iOS/Routers/ModalNavigationRouter.swift +++ b/Sources/Coordination/Routers/ModalNavigationRouter.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if os(iOS) import UIKit /// This class is responsible for showing view controllers modally, as it is a concrete implementation of the `Router` protocol. @@ -88,3 +89,4 @@ private extension ModalNavigationRouter { } } +#endif diff --git a/Sources/Coordination/Platform/Apple/iOS/Routers/PushNavigationRouter.swift b/Sources/Coordination/Routers/PushNavigationRouter.swift similarity index 99% rename from Sources/Coordination/Platform/Apple/iOS/Routers/PushNavigationRouter.swift rename to Sources/Coordination/Routers/PushNavigationRouter.swift index d4e999c..8cac7fe 100644 --- a/Sources/Coordination/Platform/Apple/iOS/Routers/PushNavigationRouter.swift +++ b/Sources/Coordination/Routers/PushNavigationRouter.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if os(iOS) import UIKit /// This class is responsible for pushing view controllers into a navigation controller, as it is a concrete implementation of the `Router` protocol. @@ -66,3 +67,4 @@ extension PushNavigationRouter: Router { } } +#endif diff --git a/Sources/Coordination/Platform/Apple/iOS/Routers/WindowRouter.swift b/Sources/Coordination/Routers/WindowRouter.swift similarity index 98% rename from Sources/Coordination/Platform/Apple/iOS/Routers/WindowRouter.swift rename to Sources/Coordination/Routers/WindowRouter.swift index f9d7431..1cc887f 100644 --- a/Sources/Coordination/Platform/Apple/iOS/Routers/WindowRouter.swift +++ b/Sources/Coordination/Routers/WindowRouter.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if os(iOS) import UIKit /// This class is responsible for populating the window of an application. @@ -45,3 +46,4 @@ public class WindowRouter: Router { } } +#endif diff --git a/Sources/Persistence/Classes/Fetcher.swift b/Sources/Persistence/Classes/Fetcher.swift index c69e715..e69b44e 100644 --- a/Sources/Persistence/Classes/Fetcher.swift +++ b/Sources/Persistence/Classes/Fetcher.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if canImport(Combine) && canImport(CoreData) import Combine import CoreData @@ -167,3 +168,4 @@ public enum Change: Hashable { case section(SectionUpdate) case object(ObjectUpdate) } +#endif diff --git a/Sources/Persistence/Protocols/Service.swift b/Sources/Persistence/Protocols/Service.swift index 358ebe1..0e5b67f 100644 --- a/Sources/Persistence/Protocols/Service.swift +++ b/Sources/Persistence/Protocols/Service.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if canImport(CoreData) import CoreData public protocol Service { @@ -38,3 +39,4 @@ public protocol Service { func save(childContext context: NSManagedObjectContext) throws } +#endif diff --git a/Tests/Communications/Use Cases/MakeURLRequestUseCaseTests.swift b/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift similarity index 100% rename from Tests/Communications/Use Cases/MakeURLRequestUseCaseTests.swift rename to Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift diff --git a/Tests/Coordination/Platform/iOS/Protocols/CoordinatorTests.swift b/Tests/Coordination/Cases/Protocols/CoordinatorTests.swift similarity index 99% rename from Tests/Coordination/Platform/iOS/Protocols/CoordinatorTests.swift rename to Tests/Coordination/Cases/Protocols/CoordinatorTests.swift index 4a61d28..516b323 100644 --- a/Tests/Coordination/Platform/iOS/Protocols/CoordinatorTests.swift +++ b/Tests/Coordination/Cases/Protocols/CoordinatorTests.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if canImport(UIKit) import Coordination import UIKit import XCTest @@ -139,3 +140,4 @@ final class CoordinatorTests: XCTestCase { } } +#endif diff --git a/Tests/Coordination/Platform/iOS/Helpers/TestCoordinators.swift b/Tests/Coordination/Helpers/TestCoordinators.swift similarity index 98% rename from Tests/Coordination/Platform/iOS/Helpers/TestCoordinators.swift rename to Tests/Coordination/Helpers/TestCoordinators.swift index 0379685..0212dd0 100644 --- a/Tests/Coordination/Platform/iOS/Helpers/TestCoordinators.swift +++ b/Tests/Coordination/Helpers/TestCoordinators.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if canImport(UIKit) import Coordination import UIKit @@ -108,3 +109,4 @@ class SpyRouter: Router { class SomeViewController: UIViewController {} class SomeOtherViewController: UIViewController {} +#endif diff --git a/Tests/Dependencies/Property Wrappers/DependencyTests.swift b/Tests/Dependencies/Cases/Property Wrappers/DependencyTests.swift similarity index 100% rename from Tests/Dependencies/Property Wrappers/DependencyTests.swift rename to Tests/Dependencies/Cases/Property Wrappers/DependencyTests.swift diff --git a/Tests/Dependencies/Services/DependencyServiceTests.swift b/Tests/Dependencies/Cases/Services/DependencyServiceTests.swift similarity index 100% rename from Tests/Dependencies/Services/DependencyServiceTests.swift rename to Tests/Dependencies/Cases/Services/DependencyServiceTests.swift diff --git a/Tests/Persistence/Classes/FetcherTests.swift b/Tests/Persistence/Cases/Classes/FetcherTests.swift similarity index 100% rename from Tests/Persistence/Classes/FetcherTests.swift rename to Tests/Persistence/Cases/Classes/FetcherTests.swift diff --git a/Tests/Persistence/Extensions/URL+DevicesTests.swift b/Tests/Persistence/Cases/Extensions/URL+DevicesTests.swift similarity index 100% rename from Tests/Persistence/Extensions/URL+DevicesTests.swift rename to Tests/Persistence/Cases/Extensions/URL+DevicesTests.swift