Skip to content

Releases: tomisacat/Not

Not 1.0.0

07 Jun 14:33

Choose a tag to compare

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 false

Peers are read-only. They evaluate !property through the property's getter and do not mutate the original value.

Highlights

  • @Not member macro — generates isNot* peers for eligible Bool properties
  • Smart namingisEnabledisNotEnabled, enabledisNotEnabled, isDarkModeisNotDarkMode
  • Broad property support — stored (var/let), computed (get-only and get/set), static/class, property wrappers (@State, @Published, @MainActor), and inferred Bool from = true / = false
  • Works on struct, class, and actor types, 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, and protocol
  • Naming collisions (e.g. enabled and isEnabled both → isNotEnabled) produce compile-time errors
  • Generated peers do not copy access modifiers or attributes like @MainActor from the original property

License

MIT