A handy collection of Swift Macros to boost your productivity. These macros are collected from examples in Apple's swift-syntax, Github,and the Internet.
Swift Macros transform your source code when you compile it, letting you avoid writing repetitive code by hand. During compilation, Swift expands any macros in your code before building your code as usual.
-
Xcode15.0.1,Swift5.9+
-
macOS v10.15+, iOS v13+, tvOS v13+, watchOS v6+, .macCatalyst v13+
You can use The Swift Package Manager to install SwiftMacrosLibrary
by adding the proper description to your Package.swift
file:
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
targets: [],
dependencies: [
.package(url: "https://github.com/kingnight/SwiftMacrosLibrary.git", from: "0.2.0")
]
)
Next, add SwiftMacrosLibrary
to your targets dependencies like so:
.target(
name: "YOUR_TARGET_NAME",
dependencies: [
"SwiftMacrosLibrary",
]
),
- @DictionaryStorage
- @Observable
- @MyOptionSet
- #FuncUnique
-
#addBlocker
-
#fontLiteral
-
#stringify
-
#URL
-
#myWarning
- @defaultFatalErrorImplementation
- @equatable
- @CaseDetection
- @CustomCodable
- @MetaEnum
- @NewType
- @Singleton
- @memberDeprecated
- @wrapStoredProperties
-
@AddAsync
-
@AddCompletionHandler
-
@PeerValueWithSuffixName