Not 1.0.0 — Read-only isNot* peers for Bool properties
First stable release of Not, a Swift macro that generates read-only isNot* computed properties for every eligible Bool property on a type.
Annotate a struct, class, or actor with @Not and get convenient negated getters without hand-writing them:
@Not
struct Settings {
var isDarkMode: Bool
var notificationsEnabled: Bool
}
settings.isNotDarkMode // false when isDarkMode is true
settings.isNotNotificationsEnabled // true when notificationsEnabled is falsePeers are read-only. They evaluate !property through the property's getter and do not mutate the original value.
Highlights
@Notmember macro — generatesisNot*peers for eligibleBoolproperties- Smart naming —
isEnabled→isNotEnabled,enabled→isNotEnabled,isDarkMode→isNotDarkMode - Broad property support — stored (
var/let), computed (get-only and get/set),static/class, property wrappers (@State,@Published,@MainActor), and inferredBoolfrom= true/= false - Works on
struct,class, andactortypes, including actor-isolated access - NotClient — runnable demo of all supported patterns
- Test suite — Swift Testing coverage for macro expansion, naming rules, and runtime behavior
Requirements
- Swift 6.2+
- Xcode 16+ (or a Swift 6 toolchain with macro support)
- macOS 10.15+, iOS 13+, tvOS 13+, watchOS 6+, macCatalyst 13+
Installation
dependencies: [
.package(url: "https://github.com/tomisacat/Not.git", from: "1.0.0"),
],
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(name: "Not", package: "Not"),
]
),
]Known limitations
- No support for
Bool?, setter-only properties, or properties explicitly marked@Not - Invalid on
extension,enum, andprotocol - Naming collisions (e.g.
enabledandisEnabledboth →isNotEnabled) produce compile-time errors - Generated peers do not copy access modifiers or attributes like
@MainActorfrom the original property
License
MIT