AI 编程教程中文版
官方教程中文版学习路线

原生应用开发路线

当每一次 pass 都配有 build、run 或 simulator loop 时,Codex 很适合 Apple platform projects。

📖 本篇术语速查表
英文 / 缩写中文一句话解释
应用壳app shell原生应用的基础框架和导航骨架。
SwiftUI苹果声明式 UI 框架,常用于 iOS 界面。
系统动作system action向操作系统暴露的能力,如分享、通知。

不想读完?把下面这段提示词丢给 AI 帮你跑完——帮你规划用 Codex 做原生应用开发的实战任务序列。

你是 Codex 原生应用开发实战顾问,帮我把原生应用开发拆成适合交给 Codex 的任务序列,从搭壳到调试。

【角色】
你熟悉用 Codex 做原生应用的路线:先构建应用基础壳、再重构 iOS SwiftUI 界面、再向系统暴露动作、最后调试。

【输入】
- 我的平台和框架(iOS SwiftUI / Android / 跨平台):___
- 当前进度(空项目 / 有壳 / 在做功能):___
- 最想推进的部分(壳 / 界面 / 系统集成 / 调试):___
- 我的原生开发经验:___

【工作流程】
1. 判断我处于哪个阶段,定本轮重点
2. 把当前阶段拆成可交给 Codex 的小任务
3. 标出平台特定、需真机或人验证的部分
4. 给从实现到调试的闭环

【输出规范】
▌一、当前阶段判断
▌二、本阶段任务序列(可交给 Codex 的)
▌三、需真机 / 人验证的部分
▌四、调试方法与验证点

【硬约束】
- 界面和交互要在真机 / 模拟器验证,不只看代码
- 系统权限和动作按最小必要申请
- 改动可回滚,分小步推进
- 平台特定 API 不确定时标注需查官方文档
- 不替我假设设计意图,界面需求不清先问

当每一次 pass 都配有 build、run 或 simulator loop 时,Codex 很适合 Apple platform projects。

如果你正在构建新的或已有的 iOS / macOS apps,并需要持续迭代 UI 或 debug issues,这组 use cases 很有用。

原生应用路线的核心是 CLI-first validation loop。Codex 不能只改 SwiftUI 文件然后结束,必须能说明使用了哪个 scheme、哪个 simulator、哪个 build 或 launch 命令,以及截图或日志怎么证明改动有效。

配图:

适合什么项目

适合:

  • Greenfield iOS SwiftUI app,需要 scaffold app 和 build loop。
  • Existing iPhone / iPad project,需要 Codex 识别 scheme、simulator、截图和日志。
  • macOS SwiftUI app,需要 sidebar、detail、inspector、commands、settings 等桌面结构。
  • 希望 agentic loop 依赖 xcodebuild、Tuist 或 XcodeBuildMCP,而不是手动点 Xcode GUI。

不适合:

  • 没有本地构建环境,且也没有 Codex Cloud environment。
  • 改动无法通过 build、run、simulator 或 screenshot 验证。
  • 需求跨 iOS、macOS、watchOS、visionOS,但没有明确平台优先级。

构建应用基础壳

让 Codex scaffold iOS 和 macOS apps,并建立 repeatable build loops。

Mac shell use case 更深入覆盖 sidebar-detail-inspector layouts、commands、settings 和其他 desktop-native structure。

  • Build for iOS Use Codex to scaffold iOS SwiftUI projects, keeping the build loop CLI-first with xcodebuild. iOS · Code

  • Build for macOS Use Codex to build macOS SwiftUI apps, wire a shell-first build-and-run loop, and add desktop structure. macOS · Code

  • Build a Mac app shell Use Codex and the Build macOS Apps plugin to turn an app idea into a desktop-native shell. macOS · Code

官方 iOS use case 建议:greenfield work 可以从普通 prompt 开始,让 Codex scaffold SwiftUI app,并写一个可绑定到 local environment Build action 的 build-and-launch script。已有 Xcode project 时,再引入 XcodeBuildMCP 去 list targets、选择 scheme、build、launch、capture screenshots。

Starter prompt

Scaffold or update this SwiftUI app with a CLI-first validation loop.
Prefer xcodebuild; use Tuist only if it makes the project cleaner.
If this is an existing Xcode project, list targets and schemes, choose the correct scheme, build, launch, and capture screenshots.
Keep the implementation focused on iPhone and iPad unless I explicitly ask for shared Apple-platform work.
After each change, run the smallest trustworthy validation step and report the exact scheme, simulator, and command used.

重构 iOS SwiftUI 界面

用 Codex 拆分大型 SwiftUI views,同时不改变 behavior;当 app 准备好后,再把 selected iOS flows 迁移到 Liquid Glass。

  • Refactor SwiftUI screens Use Codex and the Build iOS Apps plugin to break a long SwiftUI view into dedicated sections. iOS · Code

  • Adopt liquid glass Use Codex and the Build iOS Apps plugin to audit existing iPhone and iPad UI, then replace custom surfaces. iOS · Code

SwiftUI refactor 要保持行为不变。让 Codex 先指出拆分边界,再做小步迁移:

  1. 标出 oversized view。
  2. 提取 section 或 subview。
  3. 保留 state ownership。
  4. 保留 accessibility label 和 navigation behavior。
  5. 跑最小 build。
  6. 必要时 capture screenshot 对比。

Liquid Glass 类 UI 迁移更要谨慎。先 audit 已有 custom surfaces,再替换 selected flows,不要一次全站替换。

向系统暴露 iOS 动作

让 Codex identify app 应该通过 App Intents 暴露的 actions 和 entities,使 users 能从 system surfaces 触达 app behavior。

  • Add iOS app intents Use Codex and the Build iOS Apps plugin to identify actions and entities your app should expose through App Intents. iOS · Code

App Intents 适合暴露清晰、可重复、可命名的 app actions。不要把复杂 UI 流程硬塞进 intent。先让 Codex 识别:

  • actions
  • entities
  • parameters
  • confirmation needs
  • auth or permission assumptions
  • shortcuts / Spotlight / system surface 入口

然后再让它实现最小一组高价值 intents。

调试应用

让 Codex 在 Simulator 中 reproduce bugs,或为 macOS app 添加 telemetry,帮助 debug 和 fix issues。

  • Debug in iOS simulator Use Codex to discover the right Xcode scheme and simulator, launch the app, and inspect the UI. iOS · Code

  • Add Mac telemetry Use Codex and the Build macOS Apps plugin to add high-signal Logger events around important flows. macOS · Code

调试时给 Codex 的输入要包含:

  • failing behavior
  • device 或 simulator
  • OS version
  • scheme
  • repro steps
  • logs 或 screenshot
  • expected behavior

对于 macOS app,telemetry 不应乱打日志。只在关键 flow 周围添加 high-signal Logger events,例如 app launch、document open、sync、permission check、background task、error boundary。

推荐验证矩阵

场景最小验证
SwiftUI view refactorxcodebuild build 指定 scheme
iOS flow changesimulator launch + screenshot
App Intentbuild + intent 参数和 entity 检查
macOS shellbuild + app launch + navigation smoke
telemetrybuild + 触发关键 flow + 检查日志
Liquid Glass migrationscreenshot 对比 + accessibility check

完成标准

  • Codex 明确说明 greenfield scaffold 还是 existing project change。
  • 有可重复 build-and-launch command。
  • 已确认 scheme、target、simulator 或 macOS run target。
  • 每个 UI 改动有最小 build 或 screenshot 验证。
  • 重构不改变 state ownership 和 navigation behavior。
  • App Intents 只暴露清晰、有价值、可验证的动作。
  • Debug 任务有 repro steps、logs、修复 diff 和验证结果。

官方资料

本页目录