Skip to content

Commit

Permalink
added SpryMacroAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
NikSativa committed Sep 17, 2024
1 parent 78ce3b5 commit e4a3e0b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -40,6 +42,7 @@ let package = Package(
// public
.target(name: "SpryKit",
dependencies: [
"SpryMacroAvailable",
"SharedTypes",
"MacroAndCompilerPlugin",
"CwlPreconditionTesting",
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ __Table of Contents__
* [SpryEquatable](#spryequatable)
* [Argument](#Argument)
* [ArgumentCaptor](#argumentcaptor)
* [MacroAvailable](#MacroAvailable)

## Motivation

Expand Down Expand Up @@ -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!
2 changes: 1 addition & 1 deletion Tests/ThreadSafeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class ThreadSafeTests: XCTestCase {
}
}

wait(for: expectetions, timeout: 5)
wait(for: expectetions, timeout: 10)
XCTAssertEqual(storage.values.count, expectetions.count)
}
}
Expand Down
3 changes: 3 additions & 0 deletions VersionMarkerModule/Empty.swift
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit e4a3e0b

Please sign in to comment.