From e4a3e0bdc8ff6fc1d397de157fec7c4d18c57950 Mon Sep 17 00:00:00 2001 From: Mykyta Konopelko Date: Tue, 17 Sep 2024 10:38:51 +0300 Subject: [PATCH] added SpryMacroAvailable --- Package.swift | 3 +++ README.md | 15 +++++++++++++++ Tests/ThreadSafeTests.swift | 2 +- VersionMarkerModule/Empty.swift | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 VersionMarkerModule/Empty.swift diff --git a/Package.swift b/Package.swift index e8bad15..c853481 100644 --- a/Package.swift +++ b/Package.swift @@ -21,6 +21,8 @@ let package = Package( .package(url: "https://github.com/apple/swift-syntax.git", exact: "600.0.0") ], targets: [ + .target(name: "SpryMacroAvailable", + path: "VersionMarkerModule"), // internal .target(name: "SharedTypes", dependencies: [ @@ -40,6 +42,7 @@ let package = Package( // public .target(name: "SpryKit", dependencies: [ + "SpryMacroAvailable", "SharedTypes", "MacroAndCompilerPlugin", "CwlPreconditionTesting", diff --git a/README.md b/README.md index a0f5d55..7a74cc7 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ __Table of Contents__ * [SpryEquatable](#spryequatable) * [Argument](#Argument) * [ArgumentCaptor](#argumentcaptor) +* [MacroAvailable](#MacroAvailable) ## Motivation @@ -438,6 +439,20 @@ let secondArgFromFirstCall: String = captor[0] let secondArgFromSecondCall: String = captor[1] ``` +## MacroAvailable + +All the ideas described in the following apply to all packages that depend on SpryKit, not only macros. + +In order to handle breaking API changes, clients can wrap uses of such APIs in conditional compilation clauses that check MacroAvailable. + +```swift +#if canImport(SpryMacroAvailable) +// code to support @Spryable +#else +// code for SpryKit without Macro +#endif +``` + ## Contributing If you have an idea that can make SpryKit better, please don't hesitate to submit a pull request! diff --git a/Tests/ThreadSafeTests.swift b/Tests/ThreadSafeTests.swift index b46ffcd..1ab4059 100644 --- a/Tests/ThreadSafeTests.swift +++ b/Tests/ThreadSafeTests.swift @@ -27,7 +27,7 @@ final class ThreadSafeTests: XCTestCase { } } - wait(for: expectetions, timeout: 5) + wait(for: expectetions, timeout: 10) XCTAssertEqual(storage.values.count, expectetions.count) } } diff --git a/VersionMarkerModule/Empty.swift b/VersionMarkerModule/Empty.swift new file mode 100644 index 0000000..57c158e --- /dev/null +++ b/VersionMarkerModule/Empty.swift @@ -0,0 +1,3 @@ +// The SpryMacroAvailable module is intentionally empty. +// It serves as an indicator of whether @Spryable-macro is available. +// See the 'README -> #MacroAvailable' document for more information.