swift-app-macros

0.4.0

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

What's New

0.4.0

2026-10-03T19:58:39Z

Added

  • @AutoEquatableView gives reusable SwiftUI views an equality boundary when
    their parent-owned inputs can be compared. Views with closures, bindings,
    replaceable observable sources, or explicitly skipped content keep ordinary
    update behavior. This avoids retaining stale actions or child views.

Changed

  • Breaking for older development toolchains: Pin swift-syntax 604.0.0,
    aligned with Swift 6.4. Version 0.4.0 is validated with Xcode 27.0 and
    Apple Swift 6.4. Use Xcode 27.0 for this release; projects that must stay on
    Xcode 26.4 can continue using AppMacros 0.3.0. The deployment minimum stays
    iOS 26 / macOS 26.

AppMacros

Swift Platforms

Generate equality for Swift structs and use it to suppress SwiftUI view updates when parent inputs are equal.

The AppMacros library provides four APIs:

API Purpose
@Equatable Generate == and Equatable conformance from stored properties
@SkipEquatable Exclude a stored property from comparison
EquatableBodyView Apply .equatable() through the view's default body
@AutoEquatableView Generate a gated body for comparable inputs, with an ordinary View fallback for unsafe parent inputs

Quick start

EquatableBodyView defines a view with an equality boundary. Implement equatableBody and use the view directly from SwiftUI.

import AppMacros
import SwiftUI

@Equatable
struct CounterRow: @MainActor EquatableBodyView {
    let value: Int

    var equatableBody: some View {
        Text(value.formatted())
    }
}

struct CounterScreen: View {
    let count: Int

    var body: some View {
        CounterRow(value: count)
    }
}

For a regular View, attach @Equatable and apply .equatable() where it is used. For reusable views that can receive actions, bindings, or arbitrary child views, @AutoEquatableView chooses the gate only when all parent-owned inputs are safe to compare. See the adaptive view guide. Ordinary View equality and its conformance are MainActor-isolated. The .mainActor and .nonisolated arguments select isolation explicitly; .extension selects the placement of the comparison function.

Compared properties must capture the values that determine the view's display and actions. Closures and known SwiftUI state wrappers are excluded. A change only to an excluded property does not make the views unequal. See the usage guide for input and state ownership.

Requirements

Requirement Version
Swift tools 6.3
Swift language mode 6
Validated Xcode / compiler Xcode 27.0 / Apple Swift 6.4
Platforms iOS 26+, macOS 26+
swift-syntax 604.0.0, pinned exactly

Installation

Add the package dependency and link the AppMacros product from your target.

// swift-tools-version: 6.3
import PackageDescription

let package = Package(
    name: "YourApp",
    platforms: [.iOS(.v26), .macOS(.v26)],
    dependencies: [
        .package(url: "https://github.com/9uiLe/swift-app-macros.git", from: "0.4.0"),
    ],
    targets: [
        .target(
            name: "YourFeature",
            dependencies: [
                .product(name: "AppMacros", package: "swift-app-macros"),
            ]
        ),
    ]
)

Use a Swift tools 6.3 manifest and Xcode 27.0 for this release. In Xcode, add https://github.com/9uiLe/swift-app-macros as a package dependency and select the AppMacros library for your app target.

Documentation

The detailed guides are in Japanese.

Topic Contents
Usage guide Choose an API and define comparable inputs
Design Contracts, implementation modules, and test coverage
@Equatable Isolation, placement, property selection, generics, and diagnostics
@SkipEquatable Property exclusion and its correctness conditions
EquatableBodyView View definition and state ownership
@AutoEquatableView Safe automatic gating and fallback for reusable views
Actor isolation Swift Evolution rules, Apple API contracts, and WWDC references
Release design and operations Publication model, commands, recovery, and repository protection

Development

swift build
swift test

The suite covers macro expansion, compiled equality, and mounted macOS views. CI validates the Swift package, the iOS Simulator build, and release tooling on PRs and pushes to master. See CONTRIBUTING.md for the development environment, checks, and contribution process.

Releases and maintenance

9uiLe maintains this public repository and publishes source releases. Changes enter master through PRs. Local release commands use the owner's GitHub CLI authentication to prepare version PRs and publish commits that pass master CI. GitHub Actions runs with read-only credentials.

Each package version has an annotated Git tag and a GitHub Release containing its CHANGELOG entries. The release guide defines the workflow and publication requirements.

Community and license

Follow the Code of Conduct. Report security issues using the Security Policy.

MIT — see LICENSE.

Description

  • Swift Tools 6.3.0
View More Packages from this Author

Dependencies

Last updated: Sun Oct 25 2026 05:38:05 GMT-0900 (Hawaii-Aleutian Daylight Time)