原文核对:2026-10-13 · 中文正文 · 英文提示词与演示
场景定位
搭建 SwiftUI 项目,以 xcodebuild 或 Tuist 为主保持命令行构建循环,复杂工作再引入 XcodeBuildMCP 和专用 SwiftUI 技能。
- 难度
- 高级
- 时间跨度
- 1 小时
适合用于
- 从零搭建应用和构建流程的 iOS SwiftUI 项目。
- 需要检查 scheme、模拟器输出、截图或 UI 自动化的现有 iPhone、iPad 项目。
- 希望长时间 iOS UI 工作保持代理自主执行和命令行优先的团队。
相关工具
构建或重构 SwiftUI UI,采用 Liquid Glass 等现代模式,审计性能,并通过 XcodeBuildMCP 在模拟器调试。
Build iOS Apps ↗起步提示词
英文原文 · 可复制后按实际材料修改
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 you ran
- the exact scheme, simulator, and checks you used搭建应用与构建循环
新项目可从普通提示词开始:搭建 SwiftUI 应用,编写小型构建启动脚本,连接到本地环境的 Build 操作。
优先使用 CLI。xcodebuild 可列出 scheme,并从终端执行 build、test、archive、build-for-testing 和 test-without-building,让 Codex 无需反复转向 Xcode GUI。
接受第三方工具且希望项目生成更简洁时,可使用 Tuist,无需 GUI 即可生成和构建 Xcode 项目,并继续从终端启动。
完整 Xcode 项目需要更深自动化时,引入 XcodeBuildMCP,处理 scheme、target、模拟器控制、截图、日志和 UI 交互。
使用技能
首版往往无需技能或 MCP;进入专业任务,或需要更严格的 SwiftUI 约定时再添加。
- SwiftUI expert:涵盖广泛最佳实践的通用技能。
- SwiftUI Pro:审查现代 API、可维护性、无障碍和性能。
- Liquid Glass expert:采用 iOS 26 Liquid Glass API,使自定义组件符合系统设计。
- SwiftUI performance:检查性能迟缓或可疑视图更新路径,按优先级列出常见错误和优化收益。
- Swift concurrency expert:处理难懂错误和编译器告警。使用 GPT-5.6 Terra 时可能较少需要,但并发诊断混乱时仍有帮助。
- SwiftUI view refactor:缩小文件并统一代码风格。
- SwiftUI patterns:采用可预测的 @Observable 和 @Environment 架构模式。
安装和使用方式参阅技能文档。
迭代
首版可运行后,或已有项目中,继续调整 UI 和行为。
明确修改对象和预期方式。
说明是新仓库还是已有 Xcode 项目、必须兼容的 iOS 设备和部署目标,以及期望的验证循环。
提示词示例
向现有应用添加功能时,可以这样提出修改:
官方提示词
英文原文 · 可复制后按实际材料修改
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.实用建议
从基础开始
新项目用普通提示词搭建 SwiftUI 应用,并编写可接入本地 Build 操作的构建启动脚本,首轮通常不需要技能或 MCP。
使用小而可信的验证循环
每次修改后运行能证明受影响契约的最小命令,必要时再扩展为完整构建,避免每次编辑都付出全量构建成本。
保持 CLI 优先
用 xcodebuild 从终端列出 scheme,执行 build、test、archive、build-for-testing 或 test-without-building,让工作持续在代理循环中。
使用 XcodeBuildMCP
进入完整 Xcode 项目且需要深度自动化时使用它;scheme、target、模拟器、截图、日志和 UI 交互已超出简单 shell 命令的范围。
技术栈
| 需要 | 默认选项 | 用途 |
|---|---|---|
| UI 框架 | SwiftUISwiftUI ↗ | 快速原型化 iPhone、iPad 的视图、导航和共享状态,同时保持代码可读。 |
| 构建工具 | xcodebuild 或 TuistTuist ↗ | 让原生构建循环留在终端。 |
| 项目自动化 | XcodeBuildMCPXcodeBuildMCP ↗ | 检查 scheme 和 target、启动应用、截图并持续迭代。 |
| 分发工具 | App Store Connect CLIApp Store Connect CLI ↗ | 让代理从终端直接将构建上传 App Store。 |
展开英文原文对照
Use Codex to scaffold iOS SwiftUI projects, keep the build loop CLI-first with xcodebuild or Tuist, and add XcodeBuildMCP or focused SwiftUI skills when the work gets deeper.
Scaffold the app and build loop
For greenfield work, start with plain prompting. Ask Codex to scaffold a starter iOS SwiftUI app and write a small build-and-launch script you can wire to a Build action in a local environment.
Keep the loop CLI-first. Apple’s xcodebuild can list schemes and handle build, test, archive, build-for-testing, and test-without-building actions from the terminal, which lets Codex stay in an agentic loop instead of bouncing into the Xcode GUI.
If you want a cleaner project generator and you’re comfortable with third-party tooling, Tuist is a good next step. It can generate and build Xcode projects without needing the GUI, while still letting Codex build and launch the app from the terminal.
Use XcodeBuildMCP once you’re inside a full Xcode project and need deeper automation. That’s when schemes, targets, simulator control, screenshots, logs, and UI interaction matter enough that plain shell commands stop being the whole story.
Leverage skills
For the first pass, you often don’t need a skill or MCP server. Add skills once the work gets specialized or you want stronger SwiftUI conventions baked into the run.
- SwiftUI expert is a strong general-purpose SwiftUI skill with a lot of best practices already baked in.
- SwiftUI Pro is a broad SwiftUI review skill for modern APIs, maintainability, accessibility, and performance.
- Liquid Glass expert helps Codex adopt the new iOS 26 Liquid Glass APIs and tune custom components so they fit the latest system design.
- SwiftUI performance helps when a feature feels slow or a SwiftUI view update path looks suspicious. It scans for common SwiftUI mistakes and produces a prioritized report of what to fix and where the biggest gains are.
- Swift concurrency expert helps when cryptic errors and compiler warnings start fighting the change you want to make. On GPT-5.6 Terra, you may need it less often, but it’s still useful when Swift concurrency diagnostics get noisy.
- SwiftUI view refactor helps keep files smaller and make SwiftUI code more consistent across the repo.
- SwiftUI patterns helps reach for predictable @Observable and @Environment architecture patterns as the app grows.
To learn more about how to install and use skills, see our skills documentation.
Iterate
Once you have a first pass working, or if you’re starting from an existing project, you can start iterating on the UI or behavior.
For this part, be specific about what you want to change and how you want to change it.
Make that prompting layer explicit: tell Codex whether it’s working in a greenfield repo or an existing Xcode project, which iOS devices or deployment targets must keep working, and what validation loop you expect.
Example prompt
For example, if you want to add a feature to an existing app, you can ask Codex for a change like this:
官方提示词
英文原文 · 可复制后按实际材料修改
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.Practical tips
Start with basics
Start with plain prompting for greenfield work. Ask Codex to scaffold a starter SwiftUI app and write a small build-and-launch script you can wire to a Build action in a local environment. For that first pass, you often don’t need any skill or MCP server.
Use a small trustworthy validation loop
After each change, tell Codex to run the narrowest command that actually proves the contract you touched. Expand to broader builds later. This keeps Codex fast without pretending a full app build is required for every edit.
Keep the loop CLI-first
Keep the loop CLI-first. Apple’s xcodebuild tool can list schemes and run build, test, archive, build-for-testing, and test-without-building actions from the terminal, which lets Codex stay in an agentic loop instead of bouncing into the Xcode GUI.
Leverage XcodeBuildMCP
Use XcodeBuildMCP as soon as you are inside a full Xcode project and need deeper automation. That’s the point where schemes, targets, simulator control, screenshots, logs, and UI interaction matter enough that plain shell commands stop being the whole story.