Key takeaways
- Codex cloud tasks run on Linux: they can reason about SwiftUI but cannot compile it, so treat their pull requests as drafts until a Mac has built them.
- Local Codex runs commands in a sandbox; keep DerivedData inside the repository and resolve Swift packages before the agent starts.
- An AGENTS.md for iOS should require the agent to say when it could not build – an honest "not compiled" beats a confident guess.
- Moving logic into Swift packages without UI imports gives cloud tasks something they can actually test.
- A macOS CI job that runs xcodebuild test on every pull request closes the gap between cloud output and a shippable build.
Where Codex runs – and what each place can verify
OpenAI Codex is not one product but several surfaces sharing the same agent. For Swift work the difference between them is simple: does the surface have Xcode?
| Surface | Runs on | Builds and tests SwiftUI? | Good for |
|---|---|---|---|
| Codex CLI | Your Mac, in the terminal | Yes, through xcodebuild and the simulator | Feature work, failing tests, verified refactors |
| IDE extension | Your Mac, in a VS Code-style editor | Yes, with the same tools | Editing alongside the code |
| Codex in Xcode 26.3 | Xcode on macOS 26 | Yes, inside the IDE | Quick tasks centred on Xcode |
| Codex cloud tasks | Linux containers | No – no Xcode, no SwiftUI | Code-only changes, package tests, parallel drafts |
| Code review on GitHub | GitHub | Reads the diff | A second opinion on every pull request |
The common mistake is to treat a cloud task like a remote Mac. It can produce a well-argued SwiftUI change that has never been compiled. That is fine as long as everyone knows it – and as long as something with Xcode checks the result before it is merged.
An AGENTS.md for a Swift and SwiftUI repository
Codex reads AGENTS.md files: a personal one in ~/.codex, one at the repository root and optional ones in subfolders, where the file closest to the work takes precedence. /init drafts a first version. For an iOS app split into local Swift packages, a useful file looks like this:
# AGENTS.md
## Project
- iOS app "Tidepool" (SwiftUI, iOS 17+). App target in App/, features as local Swift packages in Packages/.
- Packages/Core and Packages/Networking import neither UIKit nor SwiftUI. Keep it that way.
## Verify your work
- UI-free packages: cd Packages/Core && swift test
- App: xcodebuild test -scheme Tidepool -destination 'platform=iOS Simulator,name=iPhone 17' -derivedDataPath .build-xcode -quiet
- If you could not run xcodebuild (for example in a cloud task), state that in the PR description.
Never claim the app was built when it was not.
## Conventions
- State: @Observable models passed through the environment. No singletons for app state.
- Concurrency: async/await only; no completion handlers or Combine in new code.
- Every view has a #Preview that uses fixtures from PreviewSupport/.
- Strings live in Localizable.xcstrings.
## Boundaries
- Do not hand-edit project.pbxproj. If a target change is needed, describe it in the PR.
- Do not touch signing, entitlements, Info.plist usage strings or PrivacyInfo.xcprivacy.
- No new package dependencies without approval.
Two choices in this file do most of the work. The honesty rule ("state that you could not build") turns an unverified change into a clearly labelled draft. And the package split – logic in packages that do not import Apple UI frameworks – gives every Codex surface, including the Linux cloud, something it can actually compile and test. Foundation on Linux covers most everyday APIs but not all, so keep Apple-only frameworks out of those packages.
Talk to an AI Code Engineer about shipping your app to the App Store.
In a free call we look at what you built, tell you honestly what stands between it and an approved release – and whether you need us at all.
Running xcodebuild inside the Codex sandbox
The local Codex CLI runs commands in a sandbox. In the common workspace-write mode it may write inside the project and temporary folders, and network access is off unless you enable it. Xcode assumes otherwise in three places:
- DerivedData. By default Xcode writes build products to a folder in your home Library, outside the workspace. Pass
-derivedDataPathwith a folder inside the repository (and ignore it in git). - Swift Package Manager. Resolving packages needs the network. Run
xcodebuild -resolvePackageDependenciesyourself before the session, or allow network access for this project only. - Simulators. Booting a simulator and running UI tests talks to system services. If the sandbox blocks that on your machine, approve the test command when Codex asks rather than switching the sandbox off globally.
The matching settings live in ~/.codex/config.toml:
approval_policy = "on-request"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = false
# add extra writable paths only when a build step really needs them
writable_roots = []
codex --full-auto is a shortcut for the same combination of workspace writes and on-request approvals. For scripted runs, codex exec takes a prompt non-interactively – for example a nightly job that runs swift test in Packages/Core and fixes failures without touching other packages. Avoid the full-access mode on the Mac that holds your signing identities.
What to hand to Codex cloud tasks on an iOS project
Cloud tasks shine when you have many small, independent changes and want them as pull requests in parallel. On an iOS codebase, sort the backlog before you delegate:
Good cloud tasks:
- Logic and tests in UI-free packages – if the environment's setup script installs the Swift toolchain for Linux,
swift testruns there. - Mechanical refactors across many files, such as renaming a model or replacing completion handlers with async functions.
- String catalogue edits, documentation, fastlane and CI configuration drafts.
- Triage: reading a crash stack trace and proposing where the bug lives.
Keep local or human: new screens and layout fixes, anything that needs a preview or a simulator, project file changes, signing and entitlements.
Remember how cloud environments treat the network and secrets: the setup script runs with internet access, while the agent phase has none by default, and secrets are only available to the setup script. That is a good reason to keep certificates and App Store Connect keys out of the environment completely – the cloud task does not need them to write code.
Close the gap with a macOS check on every pull request
The simplest way to make cloud output trustworthy is to let a Mac judge it. A minimal GitHub Actions workflow on a macOS runner:
name: ios-tests
on: pull_request
jobs:
test:
runs-on: macos-latest # use a runner image that ships Xcode 26
steps:
- uses: actions/checkout@v4
- run: xcodebuild -version
- run: xcodebuild test -scheme Tidepool -destination 'platform=iOS Simulator,name=iPhone 17' -derivedDataPath .build-xcode -quiet
When the check fails, paste the error into a follow-up task, or let local Codex reproduce and fix it on your Mac. Then use Codex code review on GitHub as a second reviewer and tell it what to look for in Swift diffs: state mutated off the main actor, retain cycles in escaping closures, missing accessibility labels, deprecated APIs. A human still approves the merge – our guide to reviewing agent-generated code describes a process sized for small teams, and the GitHub Actions playbook extends this workflow to archives and uploads.
From SwiftUI code to App Store Connect
Codex can prepare release work too: fastlane lanes, build number automation, a privacy manifest draft. Uploads need an archive built with Xcode 26 and the iOS 26 SDK on macOS, and the account holder still owns the app record, App Privacy answers and the review conversation. Codex app to the App Store walks through the full release, and Claude Code vs. Codex for mobile apps helps if you are still choosing a tool.
Our AI Code Engineers run Codex workshops on your own repository, or take over signing, CI/CD and submission in your Apple Developer account through the iOS submission service.
Codex setup checklist for SwiftUI projects
- AGENTS.md lists the xcodebuild and swift test commands and requires an honest note when a build was not possible.
- Logic that cloud tasks should test lives in Swift packages without UIKit or SwiftUI imports.
- Builds use a -derivedDataPath inside the repository; packages are resolved before sandboxed sessions.
- config.toml uses workspace-write with on-request approvals; full access is not used on signing machines.
- Cloud tasks get code-only work; screens, layout and project file changes stay local.
- A macOS CI job runs xcodebuild test on every pull request before merge.
- No certificates or App Store Connect keys live in the Codex cloud environment.
Frequently asked questions
Can Codex cloud build my iOS app?
No. Cloud tasks run in Linux containers without Xcode, so they cannot compile SwiftUI or run the simulator. They can still write code and test UI-free Swift packages. Builds happen on a Mac – yours or a macOS CI runner.
Does Codex in Xcode replace the Codex CLI?
Not entirely. Codex inside Xcode 26.3 is convenient for edits while you work in the IDE. The CLI is better for scripted runs, longer tasks and anything that combines code with git, fastlane and CI.
Can Codex edit .xcodeproj files?
It can, but hand-edited project files are fragile and hard to review. Prefer folders that stay in sync with the file system and local Swift packages, and let the agent describe target changes for a human to apply.
Can you help us release a Codex-built iOS app?
Yes. Book a free call and an AI Code Engineer looks at your project. We set up signing and CI/CD, prepare the listing and privacy details and handle the review conversation in your own account.
Free, 15 minutes, no obligation
Get your app from agent output to approved release.
Our AI Code Engineers take apps built with Claude Code, Codex, Cursor, Lovable, Base44 and co. through signing, CI/CD, store listings and review – in your own developer accounts.
AI tools, store policies and requirements change quickly – always check the current documentation of the tools and stores you use. This article is independent advice and not affiliated with or endorsed by Apple, Google, Anthropic, OpenAI or any other company or product mentioned; all trademarks belong to their owners.