Repository navigation
build(theme): actool build-tool plugin so themed snapshots pass under swift test - #1036
Merged
Merged
Conversation
… 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Restores
swift testas a working visual gate for the themed snapshot suites (issue #1032 problem statement). Option 1 landed — a SwiftPM build-tool plugin — soswift test --package-path Packages/<Kit>stays the single verification entry point; no fallbackmisetask was needed.Spike evidence (why the plugin emits two files)
NSColor(named:bundle:)swift testcopiesColors.xcassetsraw, noAssets.car, noInfo.plist)actool --compileanAssets.carinto the built.bundleInfo.plistwithCFBundleIdentifier#FAF8F3FF)CoreUI needs BOTH a compiled catalog at the bundle's resource root AND a bundle identifier; the SwiftPM CLI provides neither.
How
AssetCatalogCompilerbuild-tool plugin +.pluginproduct (Packages/GameShellKit/Plugins/AssetCatalogCompiler/). Two build commands per target:xcrun actool→Assets.car;/usr/libexec/PlistBuddy→ minimalInfo.plist. Non-source plugin outputs are copied by SwiftPM into the bundle root.plugins: [.plugin(name: "AssetCatalogCompiler", package: "GameShellKit")]— identical on both apps (mirror principle). SudokuKit/Package.swift stays at exactly 400 lines (one comment tightened).Two hazards found and fixed during verification (each reproduced first, then fixed):
…/Intermediates.noindex/BuildToolPluginIntermediates/(not the olderSourcePackages/plugins/); a first guard keyed on the old path let both run andxcodebuildfailed withMultiple 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.Info.plistwritten insidecreateBuildCommandsis 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 --stattouches no PNG)swift test --package-path Packages/SudokuKit --filter CompletionViewTests→ 3/3 pass__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 showsWrite MinesweeperUI resource-bundle Info.plist+Compile Colors.xcassets with actoolswift test --package-path Packages/GameShellKit(full) → 32/32 passtuist generate+xcodebuild build -scheme Sudoku -destination platform=macOS→BUILD SUCCEEDED, plugin reportsbuildCommands: [], oneAssets.carper bundle#if os(macOS)(returns[]elsewhere); the ubuntu gates run only lint/l10n/settings/frame-drift and never invoke swift build — seegh pr checksbelow--stricton all changed Swift files: clean; lefthook pre-commit (gitleaks / hygiene / swiftlint) passedcloses #1032
part of #1014
🤖 Generated with Claude Code