# Xcode Preview Capture

> 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. Use when this capability is needed.

- Skill: `tomevault-io/xcode-preview-capture` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/xcode-preview-capture`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/xcode-preview-capture/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/xcode-preview-capture

---


# 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_PATH` set to this repository root
  - Example: `export PREVIEW_BUILD_PATH=/absolute/path/to/XcodePreviews`

## Primary Command

Use the unified entry point first:

```bash
"${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

```bash
"${PREVIEW_BUILD_PATH}"/scripts/preview \
  --capture \
  --output /tmp/preview.png
```

## Workflow

1. Run `scripts/preview` with the requested file or `--capture`.
2. Confirm the output path exists.
3. Open `/tmp/preview*.png` and analyze the rendered UI.
4. 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 `--project` or `--workspace` explicitly.

---
> Source: [Iron-Ham/XcodePreviews](https://github.com/Iron-Ham/XcodePreviews) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-24 -->

