Building an iOS app has traditionally meant a tight loop between the Xcode GUI, the simulator, and your own keyboard. In 2026, that loop is changing. OpenAI Codex can now scaffold a SwiftUI project, run xcodebuild in an agentic cycle, capture simulator screenshots, and iterate on UI — entirely from the CLI, without you touching the Xcode interface.
This guide walks through the complete workflow: from the first greenfield scaffold to working inside an existing project with XcodeBuildMCP, with the specific skills, prompts, and validation patterns that make the loop reliable.
Why CLI-First Matters for Agentic iOS Development
The Xcode GUI is optimized for human interaction: clicking scheme selectors, pressing Run, reading console output with your eyes. An AI agent cannot do any of that. It operates through shell commands, file reads, and structured output — which means the moment your workflow depends on the Xcode GUI, the agent falls out of the loop and needs you to babysit every build.
Keeping the loop CLI-first is not an aesthetic preference. It is the architectural choice that determines whether Codex can run autonomously for minutes at a time or needs a human tap after every step. The tools that make this possible:
xcodebuild— Apple's first-party terminal tool. Handlesbuild,test,archive,build-for-testing, andtest-without-buildingactions. Lists available schemes with-list. No extra setup required.- Tuist — A third-party project generator that produces Xcode projects from a Swift manifest file. Eliminates
.xcodeprojmerge conflicts and gives Codex a structured interface for creating and modifying targets. Good choice if you want cleaner project management. - XcodeBuildMCP — A Model Context Protocol server that exposes deeper Xcode automation: scheme introspection, simulator control, screenshot capture, log streaming, and UI interaction. Necessary once you are inside an existing Xcode project and plain shell commands are not enough.
Phase 1: Greenfield Scaffold
For a new project, start without any skills or MCP servers. Plain prompting is sufficient for the initial scaffold, and adding tools before you need them adds complexity without payoff.
The Starter Prompt
OpenAI's recommended prompt for greenfield work:
Scaffold a starter SwiftUI app and add a build-and-launch script I can wire
to a `Build` action in my local environment.
Constraints:
- Stay CLI-first. Prefer Apple's `xcodebuild`; if a cleaner setup helps,
it's okay to use Tuist.
- If this repo already contains a full Xcode project, use XcodeBuildMCP to
list targets, pick the right scheme, build, launch, and capture screenshots
while you iterate.
- Reuse existing models, navigation patterns, and shared utilities when they
already exist.
- Keep the app focused on iPhone and iPad unless I explicitly ask for a
shared Apple-platform implementation.
- Use a small trustworthy validation loop after each change, then expand to
broader builds only when the narrower check passes.
- Tell me whether you treated this as a greenfield scaffold or an existing-
project change.
Deliver:
- the app scaffold or requested feature slice
- a small build-and-launch script with the exact commands
- the smallest relevant validation steps — the exact scheme, simulator,
and checks you used
This prompt does three things that matter: it establishes the CLI-first constraint up front, it asks Codex to declare whether it is treating the task as greenfield or existing-project work (so you can catch misclassifications), and it asks for the exact validation steps used — which forces Codex to be explicit about what it actually verified rather than claiming success on a build it never ran.
What Codex Delivers
After the scaffold prompt, expect:
- The project structure — an
.xcodeprojor Tuist-generated project with a working SwiftUI entry point, a content view, and anInfo.plist. - A build-and-launch script — typically a shell script wrapping
xcodebuild buildwith the scheme, destination (simulator), and configuration flags specified. Something like:
#!/bin/bash
set -euo pipefail
SCHEME="MyApp"
SIMULATOR="iPhone 16 Pro"
DERIVED_DATA="$PWD/.derivedData"
xcodebuild \
-scheme "$SCHEME" \
-destination "platform=iOS Simulator,name=$SIMULATOR" \
-derivedDataPath "$DERIVED_DATA" \
build
- A validation summary — the exact scheme, simulator, and output Codex used to confirm the build passes. If the build fails on the first pass, Codex should iterate; if it does not, add explicit instruction to fix build errors before declaring success.
Phase 2: Adding Skills
Once the scaffold is working, the next layer is skills — purpose-built instruction sets that give Codex stronger domain conventions for SwiftUI without you writing those conventions into every prompt.
Which Skill to Reach For
| Situation | Skill |
|---|---|
| First-pass UI work, general SwiftUI | SwiftUI Expert |
| Code review before a PR | SwiftUI Pro |
| Adopting iOS 26's new design system | Liquid Glass Expert |
| Views that feel slow or re-render too often | SwiftUI Performance |
async/await compiler errors or warning floods | Swift Concurrency Expert |
| Large view files, inconsistent structure | SwiftUI View Refactor |
| Growing app, needs @Observable/@Environment patterns | SwiftUI Patterns |
You typically add one skill at a time, matched to the specific problem. Adding all of them at once dilutes the signal and can produce conflicting advice.
Liquid Glass: The iOS 26 Case
iOS 26 introduced Liquid Glass, Apple's new design language that replaces many standard control appearances with translucent, fluid materials. If you are building for iOS 26 targets, the Liquid Glass Expert skill is worth adding early. It gives Codex the specific API knowledge to:
- Replace custom backgrounds with
GlassEffectand system materials - Tune custom components to pass Apple's human interface guidelines for the new system
- Avoid common mistakes where custom UI fights the system rendering layer
Without this skill, Codex will reach for older SwiftUI APIs that technically work but look inconsistent on iOS 26 devices.
Phase 3: Working Inside an Existing Project
Greenfield scaffolding is straightforward. The harder case is when you join an existing Xcode project with multiple targets, schemes, and years of accumulated architecture.
Add XcodeBuildMCP
Once you are inside an existing project, install XcodeBuildMCP. This gives Codex the ability to:
- List targets and schemes without you telling it which ones exist
- Build and launch on a specific simulator
- Capture screenshots at key moments during UI iteration
- Read logs in structured form rather than raw
xcodebuildoutput - Interact with the simulator UI for flows that require taps and navigation
The transition point is clear: when you find yourself telling Codex "the scheme is called X, the simulator is Y, use this destination flag" — that is information XcodeBuildMCP should be supplying, not you.
The Iteration Prompt Pattern
For feature work in an existing project:
Add the onboarding flow for this SwiftUI app.
Constraints:
- Reuse existing models, navigation patterns, and shared utilities.
- Use XcodeBuildMCP to list the right targets or schemes, build the app,
launch it, and capture screenshots if you need visual verification.
- Keep the implementation focused on iPhone and iPad unless I explicitly
ask for a shared iOS/macOS abstraction.
- Tell me exactly which scheme, simulator, and checks you used.
Implement the slice, verify it with the smallest relevant build or run loop,
and summarize what changed.
The key constraint is specificity: tell Codex the scope (onboarding flow only), the tooling expectation (XcodeBuildMCP), the platform constraint (iPhone and iPad), and what proof you need (exact scheme, simulator, checks used). Vague prompts produce vague validation.
The Validation Loop: Smallest Trustworthy Check First
One of the most common mistakes with agentic iOS development is letting Codex run a full app build after every small change. A full xcodebuild build on a large project can take several minutes. If Codex is making ten changes per session, that is potentially 30+ minutes of build time just on compilation — before any tests run.
The right pattern: run the narrowest command that actually proves the contract you touched, then expand.
- Changed a single view file? Build just that target.
- Added a new model? Run the unit tests for that model layer only.
- Modified navigation? Build and launch on a simulator; capture a screenshot of the flow.
- Changed nothing structural? A build-for-testing pass may be enough to catch compilation errors without running the full test suite.
Expand to broader builds only when the narrow check passes. Tell Codex this explicitly in your constraints — otherwise it will default to the safest (slowest) option every time.
Tech Stack Reference
| Need | Default Choice | Why |
|---|---|---|
| UI framework | SwiftUI | Fastest path for views, navigation, and shared state on iPhone/iPad |
| Build tooling | xcodebuild or Tuist | Keeps the build loop in the terminal |
| Project automation | XcodeBuildMCP | Scheme introspection, simulator control, screenshots, logs |
| Distribution | App Store Connect CLI | Keeps the agent fully in the distribution loop |
On the xcodebuild vs Tuist Choice
Start with xcodebuild. It requires no setup, works on any existing project, and supports every build action you need. Add Tuist if:
- You are starting a new project and want to avoid
.xcodeprojmerge conflicts - You want Codex to manage target configuration from a Swift manifest rather than through Xcode's project editor
- You have complex target graphs that benefit from Tuist's dependency graph model
Tuist does not replace xcodebuild — it generates Xcode projects that xcodebuild then builds. The combination gives you the best of both: structured project definition and a first-party build tool.
Distribution: Keeping the Agent in the Loop
The workflow does not have to end at a passing build. App Store Connect CLI lets Codex archive the app, validate it against App Store requirements, and upload it — without you opening Xcode's Organizer or the App Store Connect web interface.
For teams running automated release pipelines, this is the piece that closes the loop from "Codex wrote the feature" to "Codex submitted the build." The agent stays in the loop through distribution, not just through development.
Practical Tips Summary
Declare context upfront. Always tell Codex whether it is working in a greenfield repo or an existing Xcode project, and which deployment targets must keep working. Misclassification wastes entire sessions.
One skill at a time. Add skills when the work gets specialized — not as a precaution. Starting every session with five skills active produces noise, not signal.
Small validation loop, then expand. The narrowest command that proves the contract you touched. Broader builds only when the narrow check passes.
Ask for the exact commands. Require Codex to tell you the exact scheme, simulator, and checks it used. If it cannot answer specifically, it did not actually verify the build.
XcodeBuildMCP is the threshold tool. If you find yourself manually copying scheme names and destination flags into prompts, that is the signal to add XcodeBuildMCP and let it handle project introspection.
GPT-5.4 reduces concurrency noise. On newer models, Swift concurrency diagnostics are less likely to produce false-positive warnings. The Swift Concurrency Expert skill is still useful for genuinely complex async patterns — it is just less necessary as a default addition than it was on earlier models.
FAQ
Can Codex build a complete iOS app from scratch?
Yes — Codex can scaffold the project, write SwiftUI views, run the build loop, launch on a simulator, and iterate on UI, all from the CLI. The practical limit is complexity: very large apps with hundreds of screens and custom frameworks still benefit from more explicit human direction at the architecture level.
Do I need XcodeBuildMCP for a greenfield project?
No. For greenfield work, plain prompting with xcodebuild is sufficient for the scaffold and first iterations. XcodeBuildMCP becomes valuable when you are inside an existing project and need scheme introspection, simulator control, or screenshot capture.
What is the Liquid Glass Expert skill for?
It gives Codex specific knowledge of iOS 26's new design system — the APIs, the component patterns, and the common mistakes when adopting GlassEffect and system materials. Without it, Codex will use older SwiftUI APIs that work but look inconsistent on iOS 26 devices.
How do I prevent Codex from running slow full builds after every change?
Explicitly include a constraint in your prompt: "Use the smallest validation loop that proves the contract you touched. Only expand to a full build when the narrow check passes." Without this instruction, Codex defaults to the safest (slowest) option.
The OpenAI Codex iOS workflow is documented at platform.openai.com. XcodeBuildMCP is available as an open-source MCP server. Skills are installable via the Codex skills documentation.