[Improvement] Naming of libraries and package (#22)

This PR contains the work done to fix the naming of the libraries and the package, along with tweaks to the folder structure.

Reviewed-on: #22
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit is contained in:
Javier Cicchelli 2023-08-13 21:53:47 +00:00 committed by Javier Cicchelli
parent 060d8a84a9
commit e6e82b3b40
54 changed files with 65 additions and 53 deletions

View File

@ -14,56 +14,56 @@ import PackageDescription
// MARK: - Variables // MARK: - Variables
private var targetsLibrary: [String] = [ private var targetsLibrary: [String] = [
.Target.communications, .Target.communication,
.Target.coordination, .Target.coordination,
.Target.core, .Target.foundation,
.Target.dependencies, .Target.dependency,
] ]
private var targetsPackage: [Target] = [ private var targetsPackage: [Target] = [
.target( .target(
name: .Target.communications, name: .Target.communication,
dependencies: [] path: "Libraries/Communication"
), ),
.target( .target(
name: .Target.coordination, name: .Target.coordination,
dependencies: [] path: "Libraries/Coordination"
), ),
.target( .target(
name: .Target.core, name: .Target.foundation,
dependencies: [] path: "Libraries/Foundation"
), ),
.target( .target(
name: .Target.dependencies, name: .Target.dependency,
dependencies: [] path: "Libraries/Dependency"
), ),
.testTarget( .testTarget(
name: "CommunicationsTests", name: .Target.communication.tests,
dependencies: [ dependencies: [
.init(stringLiteral: .Target.communications) .init(stringLiteral: .Target.communication)
], ],
path: "Tests/Communications" path: "Tests/Communication"
), ),
.testTarget( .testTarget(
name: "CoordinationTests", name: .Target.coordination.tests,
dependencies: [ dependencies: [
.init(stringLiteral: .Target.coordination) .init(stringLiteral: .Target.coordination)
], ],
path: "Tests/Coordination" path: "Tests/Coordination"
), ),
.testTarget( .testTarget(
name: "CoreTests", name: .Target.foundation.tests,
dependencies: [ dependencies: [
.init(stringLiteral: .Target.core) .init(stringLiteral: .Target.foundation)
], ],
path: "Tests/Core" path: "Tests/Foundation"
), ),
.testTarget( .testTarget(
name: "DependenciesTests", name: .Target.dependency.tests,
dependencies: [ dependencies: [
.init(stringLiteral: .Target.dependencies) .init(stringLiteral: .Target.dependency)
], ],
path: "Tests/Dependencies" path: "Tests/Dependency"
), ),
] ]
@ -72,10 +72,10 @@ targetsLibrary.append(.Target.persistence)
targetsPackage.append(contentsOf: [ targetsPackage.append(contentsOf: [
.target( .target(
name: .Target.persistence, name: .Target.persistence,
dependencies: [] path: "Libraries/Persistence"
), ),
.testTarget( .testTarget(
name: "PersistenceTests", name: .Target.persistence.tests,
dependencies: [ dependencies: [
.init(stringLiteral: .Target.persistence) .init(stringLiteral: .Target.persistence)
], ],
@ -100,7 +100,7 @@ let package = Package(
], ],
products: [ products: [
.library( .library(
name: .Package.name, name: .Library.name,
targets: targetsLibrary targets: targetsLibrary
), ),
], ],
@ -112,14 +112,26 @@ let package = Package(
private extension String { private extension String {
enum Package { enum Package {
static let name = "swift-libs"
}
enum Library {
static let name = "SwiftLibs" static let name = "SwiftLibs"
} }
enum Target { enum Target {
static let communications = "Communications" static let communication = "SwiftLibsCommunication"
static let coordination = "Coordination" static let coordination = "SwiftLibsCoordination"
static let core = "Core" static let foundation = "SwiftLibsFoundation"
static let dependencies = "Dependencies" static let dependency = "SwiftLibsDependency"
static let persistence = "Persistence" static let persistence = "SwiftLibsPersistence"
}
}
// MARK: - String+Computed
private extension String {
var tests: String {
self + "Tests"
} }
} }

View File

@ -14,11 +14,11 @@ This package contains the core building blocks that we, [Röck+Cöde](https://ro
This package contains several libraries which can be imported, and these libraries are grouped by a certain concern, feature or purpose. This package contains several libraries which can be imported, and these libraries are grouped by a certain concern, feature or purpose.
To provide further details about the libraries included in this package: To provide further details about the libraries included in this package:
* `Communications`: protocols, enumerations and a ready-to-use mock url class to build remote API services; * `SwiftLibsCommunication`: protocols, enumerations and a ready-to-use mock url class to build remote API services;
* `Coordination`: protocols to implement the [Coordinator pattern](https://khanlou.com/2015/01/the-coordinator/) and some ready-to-use platform-specific concrete routers; * `SwiftLibsCoordination`: protocols to implement the [Coordinator pattern](https://khanlou.com/2015/01/the-coordinator/) and some ready-to-use platform-specific concrete routers;
* `Core`: extensions we usually add to the base layer functionality and primitive types provided by the [Swift standard library](https://https://www.swift.org/documentation/#standard-library); * `SwiftLibsDependency`: a ready-to-use, simple [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) mechanism that levers heavily on the [dynamic property wrappers](https://www.hackingwithswift.com/plus/intermediate-swiftui/creating-a-custom-property-wrapper-using-dynamicproperty) provided by the [Swift programming language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/properties/#Projecting-a-Value-From-a-Property-Wrapper);
* `Dependencies`: a ready-to-use, simple [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) mechanism that levers heavily on the [dynamic property wrappers](https://www.hackingwithswift.com/plus/intermediate-swiftui/creating-a-custom-property-wrapper-using-dynamicproperty) provided by the [Swift programming language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/properties/#Projecting-a-Value-From-a-Property-Wrapper); * `SwiftLibsFoundation`: extensions we usually add to the base layer functionality and primitive types provided by the [Swift standard library](https://https://www.swift.org/documentation/#standard-library);
* `Persistence` (*available for Apple platforms only*): protocols, extensions and a ready-to-use fetcher class to simplify the building of the [CoreData](https://developer.apple.com/documentation/coredata) persistence layer; * `SwiftLibsPersistence` (*available for Apple platforms only*): protocols, extensions and a ready-to-use fetcher class to simplify the building of the [CoreData](https://developer.apple.com/documentation/coredata) persistence layer;
## Installation ## Installation
@ -37,7 +37,7 @@ In the intended `Package.swift` file, it is required to add the following depend
```swift ```swift
dependencies: [ dependencies: [
// ... // ...
.package(url: "https://github.com/rock-n-code/swift-libs.git", from: "0.1.7") .package(url: "https://github.com/rock-n-code/swift-libs.git", from: "0.2.0")
// ... // ...
], ],
``` ```
@ -66,7 +66,7 @@ In an opened Xcode project, it is required to follow these steps to install the
4. press on the *+* (plus) button to add dependencies to the project; 4. press on the *+* (plus) button to add dependencies to the project;
5. enter the URL `https://github.com/rock-n-code/swift-libs.git` into the *Search or Enter Package URL* located in the upper right corner; 5. enter the URL `https://github.com/rock-n-code/swift-libs.git` into the *Search or Enter Package URL* located in the upper right corner;
6. select the retrieved option; 6. select the retrieved option;
7. define the dependency rule (the *Up to Next Major Version* option and the *0.1.7* text are recommended); 7. define the dependency rule (the *Up to Next Major Version* option and the *0.2.0* text are recommended);
8. select the target to which the dependency will be applied (if required); 8. select the target to which the dependency will be applied (if required);
9. wait for the package to be resolved and included in the project; 9. wait for the package to be resolved and included in the project;
10. now you should be ready to start using this package! 10. now you should be ready to start using this package!

View File

@ -10,8 +10,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Communications
import Foundation import Foundation
import SwiftLibsCommunication
import XCTest import XCTest
#if canImport(FoundationNetworking) #if canImport(FoundationNetworking)

View File

@ -10,8 +10,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Communications
import Foundation import Foundation
import SwiftLibsCommunication
struct TestEndpoint: Endpoint { struct TestEndpoint: Endpoint {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Dependencies import SwiftLibsDependency
import XCTest import XCTest
final class DependencyTests: XCTestCase { final class DependencyTests: XCTestCase {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Dependencies import SwiftLibsDependency
import XCTest import XCTest
final class DependencyServiceTests: XCTestCase { final class DependencyServiceTests: XCTestCase {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Dependencies import SwiftLibsDependency
// MARK: - Protocols // MARK: - Protocols

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core import SwiftLibsFoundation
import XCTest import XCTest
final class Bool_InitTests: XCTestCase { final class Bool_InitTests: XCTestCase {

View File

@ -10,8 +10,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core
import Foundation import Foundation
import SwiftLibsFoundation
import XCTest import XCTest
final class Bundle_LocalisationBundleTests: XCTestCase { final class Bundle_LocalisationBundleTests: XCTestCase {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core import SwiftLibsFoundation
import XCTest import XCTest
final class Collection_EmptyTests: XCTestCase { final class Collection_EmptyTests: XCTestCase {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core import SwiftLibsFoundation
import XCTest import XCTest
final class Optional_NilTests: XCTestCase { final class Optional_NilTests: XCTestCase {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core import SwiftLibsFoundation
import XCTest import XCTest
final class String_EmptyTests: XCTestCase { final class String_EmptyTests: XCTestCase {

View File

@ -10,8 +10,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core
import Foundation import Foundation
import SwiftLibsFoundation
import XCTest import XCTest
final class String_LocalisationTests: XCTestCase { final class String_LocalisationTests: XCTestCase {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core import SwiftLibsFoundation
import XCTest import XCTest
final class TimeZone_ZoneTests: XCTestCase { final class TimeZone_ZoneTests: XCTestCase {

View File

@ -10,8 +10,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core
import Foundation import Foundation
import SwiftLibsFoundation
import XCTest import XCTest
final class LossyCodableList_DecodableTests: XCTestCase { final class LossyCodableList_DecodableTests: XCTestCase {

View File

@ -13,7 +13,7 @@
import Foundation import Foundation
import XCTest import XCTest
@testable import Core @testable import SwiftLibsFoundation
final class LossyCodableList_EncodableTests: XCTestCase { final class LossyCodableList_EncodableTests: XCTestCase {

View File

@ -10,7 +10,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Core import SwiftLibsFoundation
struct TestCodableList: Codable { struct TestCodableList: Codable {
@LossyCodableList var items: [TestCodable] @LossyCodableList var items: [TestCodable]

View File

@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Combine import Combine
import Persistence import SwiftLibsPersistence
import XCTest import XCTest
final class FetcherTests: XCTestCase { final class FetcherTests: XCTestCase {

View File

@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
import Foundation import Foundation
import Persistence import SwiftLibsPersistence
import XCTest import XCTest
final class URL_DevicesTests: XCTestCase { final class URL_DevicesTests: XCTestCase {

View File

@ -12,7 +12,7 @@
import CoreData import CoreData
import Foundation import Foundation
import Persistence import SwiftLibsPersistence
struct TestPersistenceService { struct TestPersistenceService {