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 和驗證結果。

官方資料

本頁目錄