AI 程式設計教程中文版
官方教程中文版學習路線

原生應用開發路線

當每一次 pass 都配有 build、run 或 simulator loop 時,Codex 很適合 Apple platform projects。

當每一次 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 和驗證結果。

官方資料

本頁目錄