Move Swift code to async/await the same way everywhere. Macros replace ad hoc helpers, keep the old sync APIs working and help you deprecate them.
Why it exists
Swift’s async/await adoption is all-or-nothing, and you can’t easily call async functions from sync contexts. Bridging the two usually means ad hoc code and helper functions.
AwaitlessKit makes the migration easier and uniform. You add a macro instead of a helper. It generates the sync version that old callers need, and later it helps you deprecate that version, so the migration stays manageable.
AwaitlessKit bypasses Swift’s concurrency safety mechanisms, so it is a migration tool and not a permanent solution.
What it does
- @Awaitless family
- async to sync, Combine publisher or completion handler.
- @Awaitable family
- Publisher and completion-handler APIs to async/await.
- PromiseKit integration
- Conversion in both directions, as a separate product.
- @IsolatedSafe
- Thread-safe wrappers for nonisolated(unsafe) properties.
Use it
class DataService {
@Awaitless
func fetchUser(id: String) async throws -> User {
// Your async implementation
}
}When most callers use the async version, change the attribute to @Awaitless(.deprecated("Use the async version")). The sync version still works, but each call to it gets a warning. .unavailable(…) turns the warnings into errors. When none are left, remove the macro.
@IsolatedSafe covers shared state. Mark a private nonisolated(unsafe) property whose name starts with _unsafe, and it generates a safe property without the prefix.
final class Cache: Sendable {
@IsolatedSafe(writable: true)
private nonisolated(unsafe) var _unsafeItems: [String] = []
// Generates: var items: [String], read and written through a private DispatchQueue
}