published fresh until

Can the agent screenshot the SwiftUI preview it just wrote?

Summary As of November 2026, XcodePreviews documents Claude Code, Cursor and Codex setup. The Codex skill runs the preview script and reads the screenshot; set the clone path with PREVIEW_BUILD_PATH

Not for building and running iOS apps in the simulator; see ios-app-build-run-simulator-agent, xcode-26-3-apple-mcp-for-claude-code

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, XcodePreviews documents a Codex skill as well as Claude Code and Cursor setup. Do first: follow the README’s integration section for your agent, then request a preview of one SwiftUI file.

The problem

An agent writes SwiftUI from the source alone, so spacing and layout mistakes show up only when you run the app and paste a screenshot back. An r/iOSProgramming post (16 Feb 2026) shared a way to give the agent that view.

What the toolkit does

The project is Iron-Ham's XcodePreviews (earlier named Claude-XcodePreviews; MIT licence). From its README: for a Swift file with a #Preview block, it extracts the preview content, injects a temporary PreviewHost target into your Xcode project, wires up only the dependencies the file imports, builds just those modules, launches the host in the Simulator, captures a screenshot and removes the injected target. For Swift packages it creates a temporary Xcode project instead. Cached builds are claimed to take about 3 to 4 seconds (the post says about 20 seconds for a package and about 5 seconds for a single file; these are the author's numbers).

In Claude Code you install it from the plugin marketplace and run /preview path/to/MyView.swift; the README documents a Cursor skill install; the README now also documents Codex installation. Set PREVIEW_BUILD_PATH to the clone's absolute path and copy .codex/skills/xcode-preview-capture/ into ~/.codex/skills/public/xcode-preview-capture/. The skill uses scripts/preview, reads the resulting screenshot and provides UI analysis. It needs macOS, Xcode and the iOS Simulator.

What commenters said

  • It helps. Several commenters said they were plugging it in or that pasting failing UI screenshots had been a pain; one user said they were adding it to their workflow after the author's explanation. These are short endorsements, not tests.
  • Xcode's own MCP can grab previews, for one agent. A commenter says Xcode's MCP server has this capability. The author replies that it holds only with exactly one agent: with several worktrees each checkout needs its own running Xcode instance and simultaneous builds are not handled. Another commenter says the Xcode MCP is very buggy and its connection popup spams when several copies of an agent connect, and expects Apple to fix it (a prediction). See the existing thread on Xcode's MCP for setup.
  • Plugin or generic skill? A commenter asked why it is tied to Claude's plugin system; the author says it is installable as a plain skill plus scripts and that they build Claude-first.
  • Limit of screenshots. A commenter points out that padding mistakes can be seen from code, while glitches during interaction or animation need more than a still image.

What to check before using it

  • It edits your .xcodeproj temporarily and runs scripts. Use it on a clean git state so you can see what it changed, and read the scripts first.
  • Performance numbers and the "preview per worktree" advantage are from the author. Two commenters report using it; nobody posted a comparison.
  • It overlaps with Apple's SwiftUI previews in Xcode and with simulator-driving MCP servers; it adds the single-file render and screenshot step.

Sources

Started from a post by @Iron-Ham, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Can the agent screenshot the SwiftUI preview it just wrote?
Summary: As of November 2026, XcodePreviews documents Claude Code, Cursor and Codex setup. The Codex skill runs the preview script and reads the screenshot; set the clone path with `PREVIEW_BUILD_PATH`
Copy for agent
get the whatworks thread xcode-previews-screenshot-loop-swiftui and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread xcode-previews-screenshot-loop-swiftui
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks