Skip to content

build(theme): actool build-tool plugin so themed snapshots pass under swift test - #1036

Merged
wei18 merged 1 commit into
mainfrom
session/dramatic-raven-giy1
Aug 25, 2026
Merged

wei18 merged 1 commit into
mainfrom
session/dramatic-raven-giy1

Conversation

@wei18

@wei18 wei18 commented Aug 25, 2026

Copy link
Copy Markdown
Owner

What

Restores swift test as a working visual gate for the themed snapshot suites (issue #1032 problem statement). Option 1 landed — a SwiftPM build-tool plugin — so swift test --package-path Packages/<Kit> stays the single verification entry point; no fallback mise task was needed.

Spike evidence (why the plugin emits two files)

Step NSColor(named:bundle:) CompletionViewTests
Baseline (swift test copies Colors.xcassets raw, no Assets.car, no Info.plist) nil 3/3 fail, fully blank renders
Manually actool --compile an Assets.car into the built .bundle still nil 3/3 fail (renders byte-identical to baseline)
+ an Info.plist with CFBundleIdentifier resolves (#FAF8F3FF) 3/3 pass against the existing committed baselines

CoreUI needs BOTH a compiled catalog at the bundle's resource root AND a bundle identifier; the SwiftPM CLI provides neither.

How

Two hazards found and fixed during verification (each reproduced first, then fixed):

  1. Xcode collision — the plugin must be a no-op under Xcode/Tuist builds, where actool already runs. Xcode 26 hosts plugins under …/Intermediates.noindex/BuildToolPluginIntermediates/ (not the older SourcePackages/plugins/); a first guard keyed on the old path let both run and xcodebuild failed with Multiple commands produce …/Assets.car. The guard is now opt-in on the SwiftPM CLI layout <scratch>/plugins/outputs/ — an unrecognised layout means no commands (blank snapshots, documented), never a broken app build.
  2. Plan-time write — an Info.plist written inside createBuildCommands is not regenerated on incremental builds (SwiftPM caches the plan) → Info.plist doesn't exist in file system. Now a real build command produces it.

Verification (all against existing baselines — no snapshot re-recorded; git diff main --stat touches no PNG)

  • swift test --package-path Packages/SudokuKit --filter CompletionViewTests → 3/3 pass
  • SudokuKit, all 18 themed __Snapshots__ suites in one filtered run → 123 tests / 19 suites pass, 0 "does not match"
  • swift test --package-path Packages/MinesweeperKit (full) → 375/375 pass (was 42 red) — plugin log shows Write MinesweeperUI resource-bundle Info.plist + Compile Colors.xcassets with actool
  • swift test --package-path Packages/GameShellKit (full) → 32/32 pass
  • Fresh plan / incremental (plugin outputs + bundle files deleted) / no-op reruns of SudokuKit all rebuild the bundle correctly; the no-op run re-executes nothing
  • tuist generate + xcodebuild build -scheme Sudoku -destination platform=macOS → BUILD SUCCEEDED, plugin reports buildCommands: [], one Assets.car per bundle
  • Linux: plugin body is #if os(macOS) (returns [] elsewhere); the ubuntu gates run only lint/l10n/settings/frame-drift and never invoke swift build — see gh pr checks below
  • SwiftLint --strict on all changed Swift files: clean; lefthook pre-commit (gitleaks / hygiene / swiftlint) passed

closes #1032
part of #1014

🤖 Generated with Claude Code

… swift test

The SwiftPM CLI only COPIES `.xcassets` resources and writes no `Info.plist`
into the resource bundle, so `Color(name, bundle: .module)` resolved to
nothing and every themed snapshot suite rendered blank under `swift test`
(#1015 follow-up). Spike showed CoreUI needs BOTH an `Assets.car` at the
bundle root AND a `CFBundleIdentifier` — adding only the compiled catalog
still returned nil from `NSColor(named:bundle:)`.

- GameShellKit: new `AssetCatalogCompiler` build-tool plugin + product. Two
  build commands: `xcrun actool` over the target's `*.xcassets` -> `Assets.car`,
  and `PlistBuddy` -> a minimal `Info.plist` (SwiftPM copies non-source plugin
  outputs into the bundle root). Both are real command outputs — a plan-time
  write is NOT regenerated on incremental builds (SwiftPM caches the plan) and
  fails the bundle copy. Opt-in ONLY under the SwiftPM CLI work-dir layout
  (`<scratch>/plugins/outputs/`); under Xcode (Tuist app builds) it emits no
  commands — Xcode compiles the catalog itself, and a second `Assets.car`
  fails the build with "Multiple commands produce" (verified via xcodebuild,
  which also showed Xcode 26 no longer uses `SourcePackages/plugins/`).
  No-op off macOS.
- SudokuUI / MinesweeperUI: attach the plugin. SudokuKit/Package.swift stays
  at the 400-line SwiftLint ceiling (one comment tightened).
- CLAUDE.md: drop the "Known exception (#1015/#1032)" note; `swift test` is a
  valid visual gate again.

Existing committed baselines pass unchanged — no re-record:
SudokuKit CompletionViewTests 3/3 + all 18 themed suites (0 PNG diffs),
MinesweeperKit and GameShellKit full suites green; fresh / incremental
(outputs deleted) / no-op `swift test` runs all rebuild the bundle correctly;
`xcodebuild -scheme Sudoku -destination platform=macOS` succeeds with the
plugin reporting `buildCommands: []`.

closes #1032
part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 merged commit a29a020 into main Aug 25, 2026
6 checks passed
@wei18
wei18 deleted the session/dramatic-raven-giy1 branch August 25, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(theme): themed snapshot suites are red under swift test post-#1015 — restore a working visual gate

1 participant