SwiftUI preview capture toolkit for visual analysis
npx claudepluginhub iron-ham/xcodepreviewsBuild and capture SwiftUI previews for visual analysis. Supports Xcode projects, SPM packages, and standalone Swift files.
Share bugs, ideas, or general feedback.
A CLI toolset for building and capturing SwiftUI previews programmatically. Designed to work with AI coding assistants (Claude Code and Cursor) for visual analysis of UI components.
Install via the Claude Code plugin marketplace:
/plugin marketplace add Iron-Ham/XcodePreviews
/plugin install preview-build@XcodePreviews
git clone https://github.com/Iron-Ham/XcodePreviews.git ~/XcodePreviews
Copy the skill definition to your user-level commands directory:
mkdir -p ~/.claude/commands
cp ~/XcodePreviews/.claude/commands/preview.md ~/.claude/commands/
Note: The manual install expects scripts at
~/XcodePreviews. If you cloned to a different location, setPREVIEW_BUILD_PATH:export PREVIEW_BUILD_PATH=/path/to/XcodePreviews
Upgrading from
Claude-XcodePreviews? The old path~/Claude-XcodePreviewsstill works — the skill files fall back to it automatically. You can rename your clone at any time, or just leave it.
git clone https://github.com/Iron-Ham/XcodePreviews.git ~/XcodePreviews
Copy the skill to your user-level skills directory:
mkdir -p ~/.cursor/skills/preview
cp ~/XcodePreviews/.cursor/skills/preview/SKILL.md ~/.cursor/skills/preview/
If you want the preview toolkit context always available in a specific project, copy the rule to that project's .cursor/rules/ directory:
mkdir -p /path/to/your/project/.cursor/rules
cp ~/XcodePreviews/.cursor/rules/preview.mdc /path/to/your/project/.cursor/rules/
Note: Like the Claude Code install, this expects scripts at
~/XcodePreviews. SetPREVIEW_BUILD_PATHto override:export PREVIEW_BUILD_PATH=/path/to/XcodePreviews
The preview script auto-detects the best approach:
# Preview a file in an Xcode project
./scripts/preview path/to/MyView.swift
# Preview a file in an SPM package
./scripts/preview path/to/Package/Sources/Module/MyView.swift
# Specify output path
./scripts/preview MyView.swift --output ~/Desktop/preview.png
# Capture current simulator
./scripts/preview --capture-only
For standalone Swift files (system imports only):
./scripts/preview-minimal.sh MyView.swift
| Option | Description |
|---|---|
--project <path> | Xcode project file |
--workspace <path> | Xcode workspace file |
--package <path> | SPM Package.swift path |
--module <name> | Target module (auto-detected) |
--simulator <name> | Simulator name (default: iPhone 17 Pro) |
--output <path> | Output screenshot path |
--verbose | Show detailed build output |
--keep | Keep temporary files after capture |
#Preview { } contentPreviewHost target into the projectAfter installation, use the /preview command:
/preview path/to/MyView.swift
After installing the skill, ask the agent to preview a SwiftUI view:
Preview the file path/to/MyView.swift
In both cases, the assistant will:
Codex can use the same scripts through a Codex skill.
export PREVIEW_BUILD_PATH=/absolute/path/to/XcodePreviews
mkdir -p ~/.codex/skills/public/xcode-preview-capture
cp -R "$PREVIEW_BUILD_PATH"/.codex/skills/xcode-preview-capture/* \
~/.codex/skills/public/xcode-preview-capture/