tomsej/dotfiles/swiftui-snapshot-gallery
Claude Code and agent skill by tomsej/dotfiles
- community
Checking that the SKILL.md file is still in the repository.
Storybook-style remote UI gallery for SwiftUI/iOS projects. Renders every UI state to PNG via a snapshot test, builds a static HTML gallery, and deploys it to surge.sh so the user can review it on any device (e.g. iPhone) and iterate with the agent. Use when the user wants to see/discuss app UI remotely, review styling states, set up a snapshot gallery, or says "gallery", "storybook", "ukaz mi UI".
Install
npx vskill@latest install tomsej/dotfiles/swiftui-snapshot-gallerySKILL.md
SwiftUI snapshot gallery
Goal: user browses all UI states as images on a phone/browser, comments in chat, agent edits SwiftUI, regenerates, redeploys. No simulator interaction needed for review.
Architecture (3 pieces, no external dependencies)
- `PreviewFixtures.swift` in the app target — static sample data shared by
#Preview blocks and the gallery test, so both always show identical states.
- `SnapshotGalleryTests.swift` in the iOS unit-test target (host app required) —
a hand-maintained scenarios: [(name, AnyView)] registry mirroring the #Preview blocks, rendered to PNG. Skips itself (XCTSkip) unless SNAPSHOT_OUTPUT_DIR is set, so normal test runs are unaffected.
- `scripts/snapshot-gallery.sh` — runs the test via
xcodebuild, assembles
gallery/index.html (responsive grid of PNGs), optionally deploys with --deploy.
Key implementation details (hard-won, do not skip)
- Render via
UIWindowattached to the host app'sUIWindowScene
(UIApplication.shared.connectedScenes), not a bare window and not ImageRenderer — bare windows and ImageRenderer produce blank images for UIKit-backed views (List, NavigationStack).
- After
makeKeyAndVisible(), pump the run loop ~1 s so List/NavigationStack
finish their first layout pass.
drawHierarchy(in:afterScreenUpdates:true); fall back tolayer.render(in:)
when it returns false.
- Guard against silent blank output: downsample to a 32×32 gray bitmap and fail
the test when all pixels are near-white (> 250).
- Pass the output dir through xcodebuild as
TEST_RUNNER_SNAPSHOT_OUTPUT_DIR=...
(the TEST_RUNNER_ prefix is stripped inside the test process). The simulator shares the host filesystem, so the test can write directly into the repo.
- The scheme's test configuration must build the app with
ENABLE_TESTABILITY: YES
(mandatory when the scheme tests in Release), otherwise @testable import fails with "Compilation search paths unable to resolve module dependency".
- Add
gallery/to.gitignore.
Workflow
- New UI state to review → add a
#Previewblock and a matching scenario to
the registry (share sample data via PreviewFixtures).
bash scripts/snapshot-gallery.sh→ local gallery atgallery/index.html.bash scripts/snapshot-gallery.sh --deploy→ deploys to
https://<project>-gallery.surge.sh (domain via SURGE_DOMAIN env).
- Send the URL to the user; iterate: edit SwiftUI → rerun script → user reloads.
Deploy prerequisites
- One-time interactive:
npx surge login(or CI-style env vars
SURGE_LOGIN + SURGE_TOKEN; token from npx surge token).
- Check auth non-interactively:
npx surge whoami.
Setting up in a new project
Create the three pieces per the architecture above, adapted to the project:
- test target name in
-only-testing:, scheme, and simulator destination in the script; - scenario registry mirroring the project's
#Previewblocks; SURGE_DOMAINdefault in the script (<project>-gallery.surge.sh).
Script skeleton: render test → assert PNGs exist → emit gallery/index.html (grid of <figure><img></figure>, -apple-system font, dark-mode friendly) → npx --yes surge gallery $SURGE_DOMAIN when --deploy is passed. Verify with: run the script, confirm PNG count > 0 and open gallery/index.html.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingprivate_dot_agents/skill-sources/swiftui-snapshot-gallery/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tomsej/dotfiles/swiftui-snapshot-gallery)