name: xcode-preview-capture description: Build and capture SwiftUI previews for visual analysis in Codex. Use when asked to preview a Swift file, capture simulator UI, or inspect visual output from SwiftUI views.
Xcode Preview Capture (Codex)
Use this skill to build SwiftUI previews and inspect screenshots.
Prerequisites
- Xcode + iOS Simulator installed
- Swift toolchain (preview-tool auto-builds on first run)
PREVIEW_BUILD_PATHset to this repository root- Example:
export PREVIEW_BUILD_PATH=/absolute/path/to/XcodePreviews
- Example:
Primary Command
Use the unified entry point first:
"${PREVIEW_BUILD_PATH}"/scripts/preview \
"<path-to-file.swift>" \
--output /tmp/preview.png
The script auto-detects:
- Xcode project with
#Preview-> dynamic target injection - Swift Package -> SPM preview workflow
- Standalone Swift file -> minimal host build
Capture Current Simulator
"${PREVIEW_BUILD_PATH}"/scripts/preview \
--capture \
--output /tmp/preview.png
Workflow
- Run
scripts/previewwith the requested file or--capture. - Confirm the output path exists.
- Open
/tmp/preview*.pngand analyze the rendered UI. - Report structure, styling, and visible issues (alignment, clipping, contrast, etc.).
Troubleshooting
- No simulator booted: run
sim-manager.sh boot "iPhone 17 Pro". - Build failure: surface the error and suggest targeted fixes.
- Wrong project detected: pass
--projector--workspaceexplicitly.