# Xcode MCP Preview

> Build and render SwiftUI previews through Xcode MCP. Use when the user asks to render, verify, inspect, or snapshot a SwiftUI Preview or

- Skill: `ai-x-builder/xcode-mcp-preview` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add ai-x-builder/xcode-mcp-preview`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ai-x-builder/xcode-mcp-preview/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: ai-x-builder (https://skillmd.com/u/ai-x-builder)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/ai-x-builder/xcode-mcp-preview

---


# Xcode MCP Preview

## Overview

Render SwiftUI previews using Xcode's active scheme and run destination, then report whether a snapshot became available.

## Tool Availability

Before calling MCP tools, confirm the `mcp__xcode` namespace is available. If it is not available, use `tool_search` to expose Xcode MCP tools; if the tools still are not available, tell the user Xcode MCP is not connected and stop rather than attempting a non-Xcode preview path.

## Workflow

1. Discover Xcode tabs with `mcp__xcode.XcodeListWindows`.
2. Select the `tabIdentifier` for the workspace/project containing the SwiftUI file.
3. Identify the `sourceFilePath` as the path within Xcode's project organization, not necessarily an absolute filesystem path.
4. If the file has multiple previews and the user specifies one, count preview declarations from the top using zero-based indexes and pass `previewDefinitionIndexInFile`; the first preview is `0`, the second is `1`.
5. Call `mcp__xcode.RenderPreview` with a reasonable timeout. Use a longer timeout for large projects.
6. If rendering fails, inspect `mcp__xcode.GetBuildLog` and `mcp__xcode.XcodeListNavigatorIssues`.

## Variant Overrides

- If a previous `RenderPreview` result lists `supportedPreviewVariantOverrides`, use only those exact group and variant names.
- Do not invent preview variant names.
- When the user does not request a variant, render the default variant.

## Reporting

- State the source file path, preview index, and selected Xcode tab.
- Report whether the preview rendered, failed to build, timed out, or could not be found.
- Include relevant build errors if preview rendering fails.

## Constraints

- Use this only for SwiftUI previews; for full app launch or Simulator interaction, use a separate simulator/debugging workflow if available.
- If no simulator/debugging workflow is available, report that this skill only covers SwiftUI preview rendering instead of inventing an app launch path.
- Do not edit preview code unless the user asks for a fix.

