diff --git a/Package.swift b/Package.swift index f640f645..0da26597 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.0 +// swift-tools-version: 6.3 import CompilerPluginSupport import PackageDescription @@ -25,6 +25,14 @@ let package = Package( targets: ["DependenciesTestSupport"] ), ], + traits: [ + "Clocks", + "CombineSchedulers", + "Foundation", + .default(enabledTraits: [ + "Clocks", "CombineSchedulers", "Foundation" + ]) + ], dependencies: [ .package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.2"), .package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.4"), @@ -42,9 +50,21 @@ let package = Package( .target( name: "Dependencies", dependencies: [ - .product(name: "Clocks", package: "swift-clocks"), - .product(name: "CombineSchedulers", package: "combine-schedulers"), - .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"), + .product( + name: "Clocks", + package: "swift-clocks", + condition: .when(traits: ["Clocks"]) + ), + .product( + name: "CombineSchedulers", + package: "combine-schedulers", + condition: .when(traits: ["CombineSchedulers"]) + ), + .product( + name: "ConcurrencyExtras", + package: "swift-concurrency-extras", + condition: .when(traits: ["Foundation"]) + ), .product(name: "IssueReporting", package: "xctest-dynamic-overlay"), .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"), ] diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift index 02174ad6..21d54c8e 100644 --- a/Package@swift-5.9.swift +++ b/Package@swift-5.9.swift @@ -43,6 +43,11 @@ let package = Package( .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"), .product(name: "IssueReporting", package: "xctest-dynamic-overlay"), .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"), + ], + swiftSettings: [ + .define("Clocks"), + .define("CombineSchedulers"), + .define("Foundation"), ] ), .testTarget( diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift new file mode 100644 index 00000000..6ca38398 --- /dev/null +++ b/Package@swift-6.0.swift @@ -0,0 +1,125 @@ +// swift-tools-version: 6.0 + +import CompilerPluginSupport +import PackageDescription + +let package = Package( + name: "swift-dependencies", + platforms: [ + .iOS(.v13), + .macOS(.v10_15), + .tvOS(.v13), + .watchOS(.v6), + ], + products: [ + .library( + name: "Dependencies", + targets: ["Dependencies"] + ), + .library( + name: "DependenciesMacros", + targets: ["DependenciesMacros"] + ), + .library( + name: "DependenciesTestSupport", + targets: ["DependenciesTestSupport"] + ), + ], + dependencies: [ + .package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.2"), + .package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.4"), + .package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"), + .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.4.0"), + .package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"603.0.0"), + ], + targets: [ + .target( + name: "DependenciesTestObserver", + dependencies: [ + .product(name: "IssueReporting", package: "xctest-dynamic-overlay") + ] + ), + .target( + name: "Dependencies", + dependencies: [ + .product(name: "Clocks", package: "swift-clocks"), + .product(name: "CombineSchedulers", package: "combine-schedulers"), + .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"), + .product(name: "IssueReporting", package: "xctest-dynamic-overlay"), + .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"), + ], + swiftSettings: [ + .define("Clocks"), + .define("CombineSchedulers"), + .define("Foundation"), + ] + ), + .target( + name: "DependenciesTestSupport", + dependencies: [ + "Dependencies", + .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"), + .product(name: "IssueReportingTestSupport", package: "xctest-dynamic-overlay"), + ] + ), + .testTarget( + name: "DependenciesTests", + dependencies: [ + "Dependencies", + "DependenciesTestSupport", + .product(name: "IssueReportingTestSupport", package: "xctest-dynamic-overlay"), + ], + exclude: ["Dependencies.xctestplan"] + ), + .target( + name: "DependenciesMacros", + dependencies: [ + "DependenciesMacrosPlugin", + .product(name: "IssueReporting", package: "xctest-dynamic-overlay"), + .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"), + ] + ), + .macro( + name: "DependenciesMacrosPlugin", + dependencies: [ + .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), + .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), + ] + ), + ], + swiftLanguageModes: [.v6] +) + +#if !os(macOS) && !os(WASI) + package.products.append( + .library( + name: "DependenciesTestObserver", + type: .dynamic, + targets: ["DependenciesTestObserver"] + ) + ) +#endif + +#if !os(WASI) + package.dependencies.append( + .package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.2.0") + ) + package.targets.append(contentsOf: [ + .testTarget( + name: "DependenciesMacrosPluginTests", + dependencies: [ + "Dependencies", + "DependenciesMacros", + "DependenciesMacrosPlugin", + .product(name: "MacroTesting", package: "swift-macro-testing"), + ] + ) + ]) +#endif + +#if !os(Windows) + // Add the documentation compiler plugin if possible + package.dependencies.append( + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0") + ) +#endif diff --git a/Sources/Dependencies/DependencyValues/Calendar.swift b/Sources/Dependencies/DependencyValues/Calendar.swift index a8f2e4d1..dec72c47 100644 --- a/Sources/Dependencies/DependencyValues/Calendar.swift +++ b/Sources/Dependencies/DependencyValues/Calendar.swift @@ -1,3 +1,4 @@ +#if Foundation import Foundation extension DependencyValues { @@ -43,3 +44,4 @@ extension DependencyValues { #endif } } +#endif diff --git a/Sources/Dependencies/DependencyValues/Clocks.swift b/Sources/Dependencies/DependencyValues/Clocks.swift index a6bc0547..ef0eb455 100644 --- a/Sources/Dependencies/DependencyValues/Clocks.swift +++ b/Sources/Dependencies/DependencyValues/Clocks.swift @@ -1,3 +1,4 @@ +#if Clocks #if (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst)) @available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) extension DependencyValues { @@ -78,3 +79,4 @@ } } #endif +#endif diff --git a/Sources/Dependencies/DependencyValues/Date.swift b/Sources/Dependencies/DependencyValues/Date.swift index ce135785..afa6238f 100644 --- a/Sources/Dependencies/DependencyValues/Date.swift +++ b/Sources/Dependencies/DependencyValues/Date.swift @@ -1,3 +1,4 @@ +#if Foundation import Foundation extension DependencyValues { @@ -73,3 +74,4 @@ public struct DateGenerator: Sendable { self.generate() } } +#endif diff --git a/Sources/Dependencies/DependencyValues/Locale.swift b/Sources/Dependencies/DependencyValues/Locale.swift index 789679fe..cb86218c 100644 --- a/Sources/Dependencies/DependencyValues/Locale.swift +++ b/Sources/Dependencies/DependencyValues/Locale.swift @@ -1,3 +1,4 @@ +#if Foundation import Foundation extension DependencyValues { @@ -56,3 +57,4 @@ extension DependencyValues { #endif } } +#endif diff --git a/Sources/Dependencies/DependencyValues/MainQueue.swift b/Sources/Dependencies/DependencyValues/MainQueue.swift index 60e54bb3..65a7440c 100644 --- a/Sources/Dependencies/DependencyValues/MainQueue.swift +++ b/Sources/Dependencies/DependencyValues/MainQueue.swift @@ -1,3 +1,4 @@ +#if CombineSchedulers #if canImport(Combine) import Foundation @@ -62,3 +63,4 @@ } } #endif +#endif diff --git a/Sources/Dependencies/DependencyValues/MainRunLoop.swift b/Sources/Dependencies/DependencyValues/MainRunLoop.swift index ddf702fc..5523775c 100644 --- a/Sources/Dependencies/DependencyValues/MainRunLoop.swift +++ b/Sources/Dependencies/DependencyValues/MainRunLoop.swift @@ -1,3 +1,4 @@ +#if CombineSchedulers #if canImport(Combine) import Foundation @@ -61,3 +62,4 @@ } } #endif +#endif diff --git a/Sources/Dependencies/DependencyValues/NotificationCenter.swift b/Sources/Dependencies/DependencyValues/NotificationCenter.swift index 8e857779..2ba16df2 100644 --- a/Sources/Dependencies/DependencyValues/NotificationCenter.swift +++ b/Sources/Dependencies/DependencyValues/NotificationCenter.swift @@ -1,3 +1,4 @@ +#if Foundation #if canImport(Foundation) import Foundation @@ -29,3 +30,4 @@ } } #endif +#endif diff --git a/Sources/Dependencies/DependencyValues/TimeZone.swift b/Sources/Dependencies/DependencyValues/TimeZone.swift index 390c0cc7..07a2a9f6 100644 --- a/Sources/Dependencies/DependencyValues/TimeZone.swift +++ b/Sources/Dependencies/DependencyValues/TimeZone.swift @@ -1,3 +1,4 @@ +#if Foundation import Foundation extension DependencyValues { @@ -42,3 +43,4 @@ extension DependencyValues { #endif } } +#endif diff --git a/Sources/Dependencies/DependencyValues/URLSession.swift b/Sources/Dependencies/DependencyValues/URLSession.swift index e4a9c1b2..5a18f019 100644 --- a/Sources/Dependencies/DependencyValues/URLSession.swift +++ b/Sources/Dependencies/DependencyValues/URLSession.swift @@ -1,3 +1,4 @@ +#if Foundation #if !os(WASI) import Foundation @@ -113,3 +114,4 @@ } } #endif +#endif diff --git a/Sources/Dependencies/DependencyValues/UUID.swift b/Sources/Dependencies/DependencyValues/UUID.swift index 5eaabc0b..98d9dbdf 100644 --- a/Sources/Dependencies/DependencyValues/UUID.swift +++ b/Sources/Dependencies/DependencyValues/UUID.swift @@ -1,3 +1,4 @@ +#if Foundation import Foundation extension DependencyValues { @@ -147,3 +148,4 @@ private struct IncrementingUUIDGenerator: Sendable { } } } +#endif diff --git a/Sources/Dependencies/Internal/Exports.swift b/Sources/Dependencies/Internal/Exports.swift index 9f85de37..25d31340 100644 --- a/Sources/Dependencies/Internal/Exports.swift +++ b/Sources/Dependencies/Internal/Exports.swift @@ -1,5 +1,11 @@ +#if Clocks @_exported import Clocks +#endif +#if CombineSchedulers @_exported import CombineSchedulers +#endif +#if Foundation @_exported import ConcurrencyExtras +#endif @_exported import IssueReporting @_exported import XCTestDynamicOverlay