Codex for iOS development: AGENTS.md, Xcode tools and skills
To use Codex for iOS development, put project rules in AGENTS.md, connect Xcode's own tools with codex mcp add xcode -- xcrun mcpbridge, and add MobileBuildMCP for simulator builds, screenshots and UI automation. SwiftUI skills such as SwiftUI Expert and SwiftUI Pro go in .agents/skills. Building and running needs a Mac with Xcode.
Last updated:
Codex can write Swift without any setup, but on an iOS project it only becomes reliable once it can build the app, see what the simulator shows, and follow your project's rules. OpenAI's own iOS use-case page recommends exactly that progression: keep the loop CLI-first with xcodebuild, then add an MCP server and focused SwiftUI skills "when the work gets deeper" (OpenAI). This guide walks through the four layers in order and links each tool to its entry on SwiftSkills. Using Cursor? →
1. Start CLI-first with xcodebuild
For a first pass you often need no MCP server or skill at all. OpenAI's guidance is to let Codex scaffold the app and a small build-and-launch script, and to stay in the terminal: Apple's xcodebuild can list schemes and run build, test, archive, build-for-testing and test-without-building actions, which keeps Codex in an agentic loop instead of bouncing into the Xcode GUI. If you prefer a project generator, the same page names Tuist as an option (OpenAI).
Two habits from that page are worth copying into every prompt: tell Codex whether the repo is greenfield or an existing Xcode project, and ask it to run "the narrowest command that actually proves the contract you touched" before a full build.
2. Give Codex your project rules with AGENTS.md
Codex reads AGENTS.md files before doing any work. It first reads a global file in ~/.codex (AGENTS.override.md if present, otherwise AGENTS.md), then walks from the project root down to your working directory and reads at most one file per directory. Files closer to your working directory come later and override earlier guidance. The combined size is capped by project_doc_max_bytes, 32 KiB by default (OpenAI).
For an iOS repo, a root AGENTS.md typically states the deployment target, the scheme and simulator to use, which build and test commands prove a change, and the SwiftUI conventions you want (for example @Observable instead of ObservableObject). You don't have to start from scratch: our rules category lists ready-made AGENTS.md files and rule packs for Swift. To check what Codex loaded, run codex --ask-for-approval never "Summarize the current instructions." from the repo root (OpenAI).
3. Connect Xcode's built-in tools
Xcode ships an MCP server for external agents. In Xcode, open Settings › Intelligence and, under Model Context Protocol, turn on "Allow external agents to use Xcode tools". Then register it in Codex:
bash
codex mcp add xcode -- xcrun mcpbridge
codex mcp listOpen your project in Xcode before prompting; Xcode shows an alert when the agent connects (Apple). Cursor's documentation describes the same bridge as available from Xcode 26.3 (Cursor). Catalog entry: Xcode MCP servers.
If you also run Codex inside Xcode (Xcode Settings › Intelligence › OpenAI), Apple's Customize agent environments says those agents read ~/Library/Developer/Xcode/CodingAssistant/codex, not your global Codex settings. MobileBuildMCP's docs say Xcode's Codex agent, at the time of writing, only supports a project-scoped .codex/config.toml and starts with a minimal PATH (MobileBuildMCP). Full setup for Codex inside Xcode →
4. Add MobileBuildMCP for simulators, screenshots and UI
OpenAI's page recommends XcodeBuildMCP once "schemes, targets, simulator control, screenshots, logs, and UI interaction matter" (OpenAI). That project is now called MobileBuildMCP; see our XcodeBuildMCP setup guide for the rename. Its documented Codex setup:
bash
codex mcp add MobileBuildMCP -- npx -y mobilebuildmcp@latest mcpor in ~/.codex/config.toml:
toml
[mcp_servers.MobileBuildMCP]
command = "npx"
args = ["-y", "mobilebuildmcp@latest", "mcp"]
tool_timeout_sec = 600The timeout matters: if you see timed out awaiting tools/call after 60s, set tool_timeout_sec inside the server block. Codex ignores a top-level tool_timeout_sec for MCP tool calls (MobileBuildMCP). Build fails? Troubleshooting → Only the simulator workflow is on by default; enable more in the project config.
Need the agent to see and tap the UI with a different tool? Compare options in iOS Simulator MCP servers and the iOS simulator MCP comparison.
5. Add SwiftUI skills when the work gets specialized
A Codex skill is a folder with a SKILL.md (required name and description) plus optional scripts and references. Codex starts with each skill's name and description and loads the full instructions only when it picks the skill. You can invoke one explicitly with /skills or by typing $ in the CLI or IDE extension (OpenAI).
Where Codex looks for local skills (OpenAI):
| Scope | Location |
|---|---|
| Repository | .agents/skills in the working directory, parent folders, and the repo root |
| User | $HOME/.agents/skills |
| Admin | /etc/codex/skills |
Many Swift skills install with npx skills add <owner>/<repo>. Some READMEs still say to copy folders into $CODEX_HOME/skills; if a skill doesn't show up, check the locations above and restart Codex.
OpenAI's iOS page names a set of skills; these are the matching entries in our catalog:
| OpenAI's description | SwiftSkills entry |
|---|---|
| SwiftUI expert, general best practices | SwiftUI Expert (AvdLee) |
| SwiftUI Pro, broad review | SwiftUI Pro |
| Liquid Glass expert | SwiftUI Liquid Glass |
| SwiftUI performance | SwiftUI Performance Audit |
| Swift concurrency expert | Swift Concurrency Expert. Setup and the other concurrency skills: Swift 6 concurrency with AI agents |
| SwiftUI view refactor | SwiftUI View Refactor |
| SwiftUI patterns | SwiftUI UI Patterns |
(Mapping by name and description; OpenAI's page does not link repositories, so verify before relying on it.) For tests, add Swift Testing Pro; for UI tests see iOS UI testing with AI agents. More Swift Testing skills →. Swift Testing with AI agents compares the testing skills. More in SwiftUI agent skills. For persistence, see SwiftData with AI agents.
6. Ship from the terminal
OpenAI's stack table lists an App Store Connect CLI for distribution (OpenAI). Options in our catalog: App Store Connect CLI skills, asc-cli and MCP servers in App Store Connect MCP.
Recommended setup at a glance
| Layer | Pick | Type | Needs Xcode open? | License | Stars (2026-10-18) | Last push |
|---|---|---|---|---|---|---|
| Xcode tools | xcrun mcpbridge | MCP in Xcode 26.3+ | Yes | ships with Xcode | n/a | n/a |
| Build + simulator | MobileBuildMCP | MCP | No | MIT | 6,488 | 2026-10-17 |
| SwiftUI | SwiftUI Pro | Skill | No | MIT | 6,204 | 2026-10-16 |
| SwiftUI | SwiftUI Expert Skill | Skill | No | MIT | 3,713 | 2026-10-06 |
| SwiftUI / concurrency | Dimillian/Skills (Liquid Glass, Concurrency Expert …) | Skills (Codex) | No | MIT | 4,005 (whole repo) | 2026-03-29 ⚠ |
| Tests | Swift Testing Pro | Skill | No | MIT | 469 | 2026-05-17 |
| Shipping | App Store Connect CLI skills | Skill | No | MIT | 1,091 | 2026-10-12 |
Stars from the GitHub API, checked on 2026-10-18. License as declared on GitHub and in our catalog.
A ⚠ marks a last push more than 6 months before 2026-10-18.
FAQ
- Can Codex build and run an iOS app?
- Yes. OpenAI recommends a CLI-first loop with xcodebuild, then MobileBuildMCP (formerly XcodeBuildMCP) for simulator control, screenshots, logs and UI interaction. Building requires a Mac with Xcode.
- How do I connect Codex to Xcode?
- Enable 'Allow external agents to use Xcode tools' in Xcode Settings > Intelligence, then run codex mcp add xcode -- xcrun mcpbridge and keep your project open in Xcode.
- Where does Codex read project instructions and skills from?
- Instructions from AGENTS.md (global in ~/.codex, then from the repo root down). Local skills from .agents/skills in the repo and $HOME/.agents/skills.
- Why do MobileBuildMCP calls time out in Codex?
- Codex's default MCP tool timeout can be too short for builds. Set tool_timeout_sec = 600 inside the [mcp_servers.MobileBuildMCP] block; a top-level value is ignored.
- Does Codex need Xcode open for iOS work?
- Only for Xcode's own tools on the Xcode 26.3 flow: Apple's setup page says to open the project in Xcode before prompting, because xcrun mcpbridge talks to the running Xcode. Xcode 27 adds a headless preview (sudo xcrun mcp-server enable) that runs without an open Xcode workspace, per Apple's Xcode 27 release notes. MobileBuildMCP and xcodebuild work without Xcode open, but Xcode must be installed.