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 |
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.
| Requirement | Version |
|---|---|
| Swift tools | 6.3 |
| Swift language mode | 6 |
| Platforms | iOS 26+, macOS 26+ |
| swift-syntax | 603.0.2, pinned exactly |
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.
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 |
swift build
swift testThe 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.
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.
Follow the Code of Conduct. Report security issues using the Security Policy.
MIT — see LICENSE.