swift-app-macros

0.2.0

Production-oriented Swift macros for app development: @Equatable, @SkipEquatable, and EquatableBodyView for SwiftUI redraw optimization
9uiLe/swift-app-macros

What's New

0.2.0

2026-07-14T16:37:32Z

This release tightens generated equality so SwiftUI redraw suppression remains safe as view state and property shapes become more complex.

Changed

  • Breaking: @State properties are excluded from generated ==. This supports non-Equatable state such as @Observable models without comparing stale initializer snapshots.
  • Dynamic-property exclusion follows witness isolation, including when @Equatable(.extension) is forced on a View.
  • Breaking: stored properties declared inside #if now require explicit @SkipEquatable instead of being silently excluded.
  • Breaking: types that contain function types now require explicit @SkipEquatable; top-level callbacks remain automatically excluded.
  • A new warning identifies comparisons where every input is excluded and generated == is constant true.
  • EquatableBodyView now permits owned @StateObject state and diagnoses parent-swappable @Bindable sources.

Added

  • Mounted NSHostingView tests verify that equal inputs suppress equatableBody evaluation while parent invalidations and changed inputs still propagate.

Requirements

Swift tools 6.3 (Xcode 26.4+), iOS 26+, macOS 26+, swift-syntax 603.0.2.

See the full changelog.

AppMacros

Swift Platforms

Production-oriented Swift macros for app development.

swift-app-macros ships AppMacros: SwiftUI redraw optimization via @Equatable, @SkipEquatable, and EquatableBodyView.

Quick start

import AppMacros
import SwiftUI

@Equatable
struct CounterRow: EquatableBodyView {
    let value: Int

    var equatableBody: some View {
        Text("\(value)")
    }
}

// No `.equatable()` at call sites — baked into EquatableBodyView.
CounterRow(value: 1)

For intermediate views, use @Equatable and apply .equatable() at the call site.

Compatibility

Requirement Version
Swift tools 6.3 (swiftLanguageModes: [.v6])
Platforms iOS 26+, macOS 26+
swift-syntax 603.0.2 (exact pin)

This is an early package targeting the latest Apple SDKs. Older OS / Swift versions are not supported.

Installation

// Package.swift
dependencies: [
    .package(url: "https://github.com/9uiLe/swift-app-macros.git", from: "0.2.0"),
],
targets: [
    .target(name: "YourFeature", dependencies: [
        .product(name: "AppMacros", package: "swift-app-macros"),
    ]),
]

Documentation

The three APIs and the reasoning behind them are documented in docs/:

Topic Summary
Rationale Why an Equatable macro — the SwiftUI / Swift 6 pitfalls it removes
@Equatable Generated conformance: generation form, auto-exclusions, generics, examples
@SkipEquatable Exclude a specific stored property from comparison
EquatableBodyView Bake .equatable() into the view definition
Adoption guide Safe adoption checklist and known limitations

Testing

swift test   # 50 tests / 4 suites

CI runs on pull requests (.github/workflows/ci.yml).

Changelog

Release notes are in CHANGELOG.md.

Contributing

Contributions are welcome — see CONTRIBUTING.md and the Code of Conduct. For security issues, follow the Security Policy instead of opening a public issue.

License

MIT — see LICENSE.

Description

  • Swift Tools 6.3.0
View More Packages from this Author

Dependencies

Last updated: Sun Jul 26 2026 05:21:36 GMT-0900 (Hawaii-Aleutian Daylight Time)