From b123aa0fa4dc53ece147c04b6dc154f1f6fcb5fc Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Wed, 26 Apr 2023 15:07:46 +0200 Subject: [PATCH 01/14] Updated the Swift tools version in the Package file to v5.7. --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 8d07528..2789210 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.5 +// swift-tools-version: 5.7 // // This source file is part of the SwiftLibs open source project // -- 2.47.1 From d7e5123b5ea0c846c1b8dce6fc0a0466302d99f2 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Thu, 27 Apr 2023 02:29:43 +0200 Subject: [PATCH 02/14] Added the .env file to the .gitignore file. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3b29812..74a674f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ DerivedData/ .swiftpm/config/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .netrc +.env \ No newline at end of file -- 2.47.1 From 58a3fc9ff7e2df8d74a0672cff53ff7b1f9d3b1a Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Thu, 27 Apr 2023 02:34:04 +0200 Subject: [PATCH 03/14] Implemented the docker build and housekeeping workflows in the Makefile file. --- Makefile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ef3f514 --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +# --- IMPORTS --- + +# Imports environment variables. +environment_vars ?= .env + +include $(environment_vars) +export $(shell sed 's/=.*//' $(environment_vars)) + +# --- ARGUMENTS --- + +override tag?=${DOCKER_IMAGE_TAG} +override platform?=${DOCKER_IMAGE_PLATFORM} +override config?=${SWIFT_BUILD_CONFIGURATION} + +# --- BUILDING --- + +build: build-image remove-image ## Build this package against a Swift docker instance. + +build-image: + @docker run \ + --rm \ + --volume ${PWD}:${DOCKER_VOLUME_TARGET} \ + --workdir ${DOCKER_VOLUME_TARGET} \ + --platform ${platform} \ + ${DOCKER_IMAGE_NAME}:${tag} \ + swift build --configuration ${config} + +remove-image: + @docker rmi ${DOCKER_IMAGE_NAME}:${tag} + +# --- HOUSEKEEPING --- + +remove-images: ## Remove all outstanding Swift docker images. + @docker images --all | grep ${DOCKER_IMAGE_NAME} | awk '{print $$3}' | xargs docker rmi --force + +clean: ## Clean the build artifacts for the package. + @swift package clean + +reset: ## Reset the build folder for the package. + @swift package reset + +# --- HELP --- + +# Outputs the documentation for each of the defined tasks when `help` is called. +# Reference: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +.PHONY: help + +help: ## Prints the written documentation for all the defined tasks. + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +.DEFAULT_GOAL := help \ No newline at end of file -- 2.47.1 From ec3c6103944c9bd7477931ca73f319c5e155f5d7 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Thu, 27 Apr 2023 14:26:58 +0200 Subject: [PATCH 04/14] Added the .vscode hidden folder to the .gitignore file. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 74a674f..9411668 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store /.build +/.vscode /Packages /*.xcodeproj xcuserdata/ -- 2.47.1 From 7a0f67713dfbc164f7eccd9dd0be88b19929af5a Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Thu, 27 Apr 2023 14:30:20 +0200 Subject: [PATCH 05/14] Improved the overall implementation of the existing targets in the Makefile file. --- Makefile | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index ef3f514..5ea7cc7 100644 --- a/Makefile +++ b/Makefile @@ -8,37 +8,55 @@ export $(shell sed 's/=.*//' $(environment_vars)) # --- ARGUMENTS --- +override docker?=${CLI_USE_DOCKER} override tag?=${DOCKER_IMAGE_TAG} override platform?=${DOCKER_IMAGE_PLATFORM} override config?=${SWIFT_BUILD_CONFIGURATION} -# --- BUILDING --- +# --- DEVELOPMENT --- -build: build-image remove-image ## Build this package against a Swift docker instance. - -build-image: - @docker run \ +build: ## Build this package with Swift either locally or in a Docker image. +ifeq ($(docker),yes) + @-docker run \ --rm \ --volume ${PWD}:${DOCKER_VOLUME_TARGET} \ --workdir ${DOCKER_VOLUME_TARGET} \ --platform ${platform} \ ${DOCKER_IMAGE_NAME}:${tag} \ swift build --configuration ${config} - -remove-image: @docker rmi ${DOCKER_IMAGE_NAME}:${tag} +else + @swift build --configuration ${config} +endif -# --- HOUSEKEEPING --- +# --- TESTING --- -remove-images: ## Remove all outstanding Swift docker images. - @docker images --all | grep ${DOCKER_IMAGE_NAME} | awk '{print $$3}' | xargs docker rmi --force +test: ## Test this package with Swift either locally or in a Docker image. +ifeq ($(docker),yes) + @-docker run \ + --rm \ + --volume ${PWD}:${DOCKER_VOLUME_TARGET} \ + --workdir ${DOCKER_VOLUME_TARGET} \ + --platform ${platform} \ + ${DOCKER_IMAGE_NAME}:${tag} \ + swift test --parallel + @docker rmi ${DOCKER_IMAGE_NAME}:${tag} +else + @swift test --parallel +endif -clean: ## Clean the build artifacts for the package. +# --- HOUSE-KEEPING --- + +clean: ## Clean the build artifacts of the package. @swift package clean -reset: ## Reset the build folder for the package. +reset: ## Reset the build folder of the package. @swift package reset +flush-images: ## Flush all outstanding Swift docker images. + @docker images \ + --all | grep ${DOCKER_IMAGE_NAME} | awk '{print $$3}' | xargs docker rmi --force + # --- HELP --- # Outputs the documentation for each of the defined tasks when `help` is called. @@ -48,4 +66,4 @@ reset: ## Reset the build folder for the package. help: ## Prints the written documentation for all the defined tasks. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) -.DEFAULT_GOAL := help \ No newline at end of file +.DEFAULT_GOAL := help -- 2.47.1 From 4cbdb135e78c114de70ce115da37d4b730bb9d27 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 14:27:40 +0200 Subject: [PATCH 06/14] Added the "outdated" and "update" targets for dependencies workflows to the Makefile file. --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 5ea7cc7..2834d9e 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,14 @@ override tag?=${DOCKER_IMAGE_TAG} override platform?=${DOCKER_IMAGE_PLATFORM} override config?=${SWIFT_BUILD_CONFIGURATION} +# --- DEPENDENCIES --- + +outdated: ## List the package dependencies that can be updated. + @swift package update --dry-run + +update: ## Update the package dependencies defined in the project. + @swift package update + # --- DEVELOPMENT --- build: ## Build this package with Swift either locally or in a Docker image. -- 2.47.1 From 9465a985afbc20bd5368feffa3f61f68b823963e Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 14:45:54 +0200 Subject: [PATCH 07/14] Added the "xcode" target to open this project with Xcode in the Makefile file. --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 2834d9e..05465f7 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,11 @@ flush-images: ## Flush all outstanding Swift docker images. @docker images \ --all | grep ${DOCKER_IMAGE_NAME} | awk '{print $$3}' | xargs docker rmi --force +# --- MISCELLANEOUS --- + +xcode: ## Open this package in Xcode. + @open -a Xcode Package.swift + # --- HELP --- # Outputs the documentation for each of the defined tasks when `help` is called. -- 2.47.1 From 01c502a4c17fdb8280ccc727ba2a9d74fb9f134b Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 16:14:02 +0200 Subject: [PATCH 08/14] Improved the "build" target in the Makefile file to make the cleaning of the docker image optional. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 05465f7..8f829e1 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ override docker?=${CLI_USE_DOCKER} override tag?=${DOCKER_IMAGE_TAG} override platform?=${DOCKER_IMAGE_PLATFORM} override config?=${SWIFT_BUILD_CONFIGURATION} +override clean?=${DOCKER_IMAGE_CLEAN} # --- DEPENDENCIES --- @@ -32,7 +33,9 @@ ifeq ($(docker),yes) --platform ${platform} \ ${DOCKER_IMAGE_NAME}:${tag} \ swift build --configuration ${config} - @docker rmi ${DOCKER_IMAGE_NAME}:${tag} + ifeq ($(clean),yes) + @docker rmi ${DOCKER_IMAGE_NAME}:${tag} + endif else @swift build --configuration ${config} endif -- 2.47.1 From 8d33cdea7ccae0a56a10bf41f4e40f0f54aa114d Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 16:16:11 +0200 Subject: [PATCH 09/14] Moved the iOS specific files of the Coordination library inside the Apple platform folder. --- .../Platform/{ => Apple}/iOS/Routers/BaseNavigationRouter.swift | 0 .../Platform/{ => Apple}/iOS/Routers/ModalNavigationRouter.swift | 0 .../Platform/{ => Apple}/iOS/Routers/PushNavigationRouter.swift | 0 .../Platform/{ => Apple}/iOS/Routers/WindowRouter.swift | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename Sources/Coordination/Platform/{ => Apple}/iOS/Routers/BaseNavigationRouter.swift (100%) rename Sources/Coordination/Platform/{ => Apple}/iOS/Routers/ModalNavigationRouter.swift (100%) rename Sources/Coordination/Platform/{ => Apple}/iOS/Routers/PushNavigationRouter.swift (100%) rename Sources/Coordination/Platform/{ => Apple}/iOS/Routers/WindowRouter.swift (100%) diff --git a/Sources/Coordination/Platform/iOS/Routers/BaseNavigationRouter.swift b/Sources/Coordination/Platform/Apple/iOS/Routers/BaseNavigationRouter.swift similarity index 100% rename from Sources/Coordination/Platform/iOS/Routers/BaseNavigationRouter.swift rename to Sources/Coordination/Platform/Apple/iOS/Routers/BaseNavigationRouter.swift diff --git a/Sources/Coordination/Platform/iOS/Routers/ModalNavigationRouter.swift b/Sources/Coordination/Platform/Apple/iOS/Routers/ModalNavigationRouter.swift similarity index 100% rename from Sources/Coordination/Platform/iOS/Routers/ModalNavigationRouter.swift rename to Sources/Coordination/Platform/Apple/iOS/Routers/ModalNavigationRouter.swift diff --git a/Sources/Coordination/Platform/iOS/Routers/PushNavigationRouter.swift b/Sources/Coordination/Platform/Apple/iOS/Routers/PushNavigationRouter.swift similarity index 100% rename from Sources/Coordination/Platform/iOS/Routers/PushNavigationRouter.swift rename to Sources/Coordination/Platform/Apple/iOS/Routers/PushNavigationRouter.swift diff --git a/Sources/Coordination/Platform/iOS/Routers/WindowRouter.swift b/Sources/Coordination/Platform/Apple/iOS/Routers/WindowRouter.swift similarity index 100% rename from Sources/Coordination/Platform/iOS/Routers/WindowRouter.swift rename to Sources/Coordination/Platform/Apple/iOS/Routers/WindowRouter.swift -- 2.47.1 From 847c2afc447bec4e649c555b619fe2d78e6e9404 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 16:54:15 +0200 Subject: [PATCH 10/14] 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 -- 2.47.1 From 9965deb2a80a940bda47b2cb8303f666bcc13624 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 19:03:33 +0200 Subject: [PATCH 11/14] Improved the "test" target in the Makefile file to make the cleaning of the docker image optional. --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8f829e1..fe8c794 100644 --- a/Makefile +++ b/Makefile @@ -50,10 +50,12 @@ ifeq ($(docker),yes) --workdir ${DOCKER_VOLUME_TARGET} \ --platform ${platform} \ ${DOCKER_IMAGE_NAME}:${tag} \ - swift test --parallel - @docker rmi ${DOCKER_IMAGE_NAME}:${tag} + swift test --configuration ${config} + ifeq ($(clean),yes) + @docker rmi ${DOCKER_IMAGE_NAME}:${tag} + endif else - @swift test --parallel + @swift test --configuration ${config} endif # --- HOUSE-KEEPING --- -- 2.47.1 From ada0d65238101bf5121e50cdcdd002fa24352bc5 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 19:04:55 +0200 Subject: [PATCH 12/14] Defined the MakeURLRequestUseCaseTests test cases to run only on Apple platforms. --- .../Cases/Use Cases/MakeURLRequestUseCaseTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift b/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift index 7499bb1..ab95f5d 100644 --- a/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift +++ b/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) import Communications import Foundation import XCTest @@ -141,3 +142,4 @@ private struct TestEndpoint: Endpoint { } } +#endif -- 2.47.1 From 23020b10a78610539ce3714b8e6c46da4bf9fc83 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 19:06:48 +0200 Subject: [PATCH 13/14] Turned off the CoreData entity generation from the TestModel core data model and moved the core data model under the Resources folder. --- Tests/Persistence/Helpers/TestEntity.swift | 29 +++++++++++++++++++ .../Helpers/TestPersistenceService.swift | 1 + .../Model.xcdatamodel/contents | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Tests/Persistence/Helpers/TestEntity.swift rename Tests/Persistence/{Helpers => Resources}/TestModel.xcdatamodeld/Model.xcdatamodel/contents (88%) diff --git a/Tests/Persistence/Helpers/TestEntity.swift b/Tests/Persistence/Helpers/TestEntity.swift new file mode 100644 index 0000000..691f3de --- /dev/null +++ b/Tests/Persistence/Helpers/TestEntity.swift @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftLibs open source project +// +// Copyright (c) 2023 Röck+Cöde VoF. and the SwiftLibs project authors +// Licensed under the EUPL 1.2 or later. +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftLibs project authors +// +//===----------------------------------------------------------------------===// + +import Foundation +import CoreData + +@objc(TestEntity) +public class TestEntity: NSManagedObject {} + +// MARK: - Fetch requests + +extension TestEntity { + + // MARK: Functions + + @nonobjc public class func fetchRequest() -> NSFetchRequest { + return NSFetchRequest(entityName: "TestEntity") + } + +} diff --git a/Tests/Persistence/Helpers/TestPersistenceService.swift b/Tests/Persistence/Helpers/TestPersistenceService.swift index 2ebb19d..bac652b 100644 --- a/Tests/Persistence/Helpers/TestPersistenceService.swift +++ b/Tests/Persistence/Helpers/TestPersistenceService.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import CoreData +import Foundation import Persistence struct TestPersistenceService { diff --git a/Tests/Persistence/Helpers/TestModel.xcdatamodeld/Model.xcdatamodel/contents b/Tests/Persistence/Resources/TestModel.xcdatamodeld/Model.xcdatamodel/contents similarity index 88% rename from Tests/Persistence/Helpers/TestModel.xcdatamodeld/Model.xcdatamodel/contents rename to Tests/Persistence/Resources/TestModel.xcdatamodeld/Model.xcdatamodel/contents index 4c66cba..e1702d8 100644 --- a/Tests/Persistence/Helpers/TestModel.xcdatamodeld/Model.xcdatamodel/contents +++ b/Tests/Persistence/Resources/TestModel.xcdatamodeld/Model.xcdatamodel/contents @@ -1,4 +1,4 @@ - + \ No newline at end of file -- 2.47.1 From f4abf84fd8d5c30f01bc8356fd61f71e397b8d2b Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 28 Apr 2023 19:12:22 +0200 Subject: [PATCH 14/14] Updated the Package file to handle support for non Apple platforms. --- Package.swift | 162 +++++++++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 73 deletions(-) diff --git a/Package.swift b/Package.swift index 2789210..f7c463c 100644 --- a/Package.swift +++ b/Package.swift @@ -11,14 +11,86 @@ import PackageDescription -private var excludePlatforms: [String] = [.PlatformFolder.iOS] +// MARK: - Variables -#if os(iOS) -excludePlatforms = [] +private var targetsLibrary: [String] = [ + .Target.communications, + .Target.coordination, + .Target.core, + .Target.dependencies, +] + +private var targetsPackage: [Target] = [ + .target( + name: .Target.communications, + dependencies: [] + ), + .target( + name: .Target.coordination, + dependencies: [] + ), + .target( + name: .Target.core, + dependencies: [] + ), + .target( + name: .Target.dependencies, + dependencies: [] + ), + .testTarget( + name: "CommunicationsTests", + dependencies: [ + .init(stringLiteral: .Target.communications) + ], + path: "Tests/Communications" + ), + .testTarget( + name: "CoordinationTests", + dependencies: [ + .init(stringLiteral: .Target.coordination) + ], + path: "Tests/Coordination" + ), + .testTarget( + name: "CoreTests", + dependencies: [ + .init(stringLiteral: .Target.core) + ], + path: "Tests/Core" + ), + .testTarget( + name: "DependenciesTests", + dependencies: [ + .init(stringLiteral: .Target.dependencies) + ], + path: "Tests/Dependencies" + ), +] + +#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) +targetsLibrary.append(.Target.persistence) +targetsPackage.append(contentsOf: [ + .target( + name: .Target.persistence, + dependencies: [] + ), + .testTarget( + name: "PersistenceTests", + dependencies: [ + .init(stringLiteral: .Target.persistence) + ], + path: "Tests/Persistence", + resources: [ + .process("Resources") + ] + ), +]) #endif +// MARK: - Package + let package = Package( - name: "SwiftLibs", + name: .Package.name, platforms: [ .iOS(.v15), .macOS(.v12), @@ -27,82 +99,26 @@ let package = Package( ], products: [ .library( - name: "SwiftLibs", - targets: [ - "Communications", - "Coordination", - "Core", - "Dependencies", - "Persistence" - ] + name: .Package.name, + targets: targetsLibrary ), ], dependencies: [], - targets: [ - .target( - name: "Communications", - dependencies: [] - ), - .target( - name: "Coordination", - dependencies: [], - exclude: excludePlatforms - ), - .target( - name: "Core", - dependencies: [] - ), - .target( - name: "Dependencies", - dependencies: [] - ), - .target( - name: "Persistence", - dependencies: [] - ), - .testTarget( - name: "CommunicationsTests", - dependencies: [ - "Communications" - ], - path: "Tests/Communications" - ), - .testTarget( - name: "CoordinationTests", - dependencies: [ - "Coordination" - ], - path: "Tests/Coordination", - exclude: excludePlatforms - ), - .testTarget( - name: "CoreTests", - dependencies: [ - "Core" - ], - path: "Tests/Core" - ), - .testTarget( - name: "DependenciesTests", - dependencies: [ - "Dependencies" - ], - path: "Tests/Dependencies" - ), - .testTarget( - name: "PersistenceTests", - dependencies: [ - "Persistence" - ], - path: "Tests/Persistence" - ), - ] + targets: targetsPackage ) // MARK: - String+Constants private extension String { - enum PlatformFolder { - static let iOS = "Platform/iOS" + enum Package { + static let name = "SwiftLibs" + } + + enum Target { + static let communications = "Communications" + static let coordination = "Coordination" + static let core = "Core" + static let dependencies = "Dependencies" + static let persistence = "Persistence" } } -- 2.47.1