swift-app-macros

0.3.0

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

What's New

0.3.0

2026-09-15T23:02:04Z

Changed

  • Breaking: Ordinary View and detected global-actor types use equality and
    Equatable conformance isolated to their actor. Directly declared conformances
    must match that isolation, such as @MainActor Equatable or
    @MainActor EquatableBodyView. See the
    usage guide.
  • EquatableBodyView compares content on MainActor.
  • SwiftUI dynamic-property exclusion is independent of isolation and expansion
    placement, including structs without a syntactically visible View conformance.
  • Invalid declarations produce diagnostics without equality or conformance generation.

Added

  • .mainActor mode for types whose isolation cannot be inferred syntactically.
  • Diagnostics for unsupported expansion expressions, conflicting equality witnesses,
    and mismatched conformance isolation, with isolation fix-its.
  • Compiled tests for non-Sendable inputs, isolated generic conformances, custom actors,
    and detached comparisons; mounted macOS rendering tests for MainActor equality.
  • Owner-authenticated release commands for preparing version PRs, checking merged
    commits against CI, and publishing immutable releases with resumable drafts.
  • Release tooling tests and CI validation on pushes to master.

Fixed

  • Generated generic constraints apply only to parameters referenced by compared
    property types.
  • Qualified and actor-annotated conformances are recognized without duplicate generation.

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 three 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

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. 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
Platforms iOS 26+, macOS 26+
swift-syntax 603.0.2, 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.3.0"),
    ],
    targets: [
        .target(
            name: "YourFeature",
            dependencies: [
                .product(name: "AppMacros", package: "swift-app-macros"),
            ]
        ),
    ]
)

Use a Swift tools 6.3 manifest. 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
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: Sat Oct 03 2026 19:30:00 GMT-0900 (Hawaii-Aleutian Daylight Time)