[教學] 實戰使用 Cursor AI 開發 iOS app 流程示範

本帖最後由 javacomhk 於 2025-4-24 22:36 編輯

實戰使用 Cursor AI Code Editor 開發 iOS app 流程示範

1. 在 Mac 下載及安裝 Cursor AI Code Editor 及登記,可在 Cursor 內加入 GPT-4.1 (參考),首次登記 Cursor AI 可免費試用14日

2. 在 Mac App Store 下載及安裝 Xcode (如果還未安裝)

3. 在 XCode 新增 iOS app 並儲存 例如在 Desktop 桌面,儲存後不需要關閉 Xcode 項目檔案




4. 開啟或切換至 Cursor 並用 Open Project 去 開啟 上述儲存好的 iOS app 的 StockPrice folder


5. 新增 .cursorrules 檔案在該 folder 下如下


.cursorrules 檔案內容從此網址 copy and paste 放入
https://cursor.directory/swiftui-swift-simple-developer-cursor-rules

6. 在 Cursor 內的 Setttings -> Features 及 Docs 下 Add new doc 加入 Apple Swift 及 Apple Design Tips  如下 url
https://developer.apple.com/documentation/swift/
https://developer.apple.com/design/tips/



7. 在 Cursor 的 New chat 窗口內 取消任何檔案選擇(代表AI tool 需要修改整個項目而不是項目中個別檔案) 並加上 Doc - Apple Swift 及 Apple Design Tips 如下


及加入以下 Prompt 內容 send 去執行及讓 AI Generate Code,Auto 是代表讓 Cursor 自動選擇合適的 AI Model
  1. I'm making an iOS stocks app. The app will have two screens:
  2. Home Screen that will show the stocks of a few popular companies-Apple, Amazon, Google, Meta, and Microsoft. For each stock, we show the current price (latest market price) and daily price change (indicates the change in value since the market opened, both in absolute value and percentage). Price change should have green if it's positive and red if it's negative.
  3. Stock details screen will screen provide in-depth data and insights for a selected stock. It should have Stock Name & Symbol (displayed at the top), current price, a linear chart showing price fluctuations throughout the day, and market stats (Opening Price, Previous Close, Daily High & Low).
複製代碼
9. 其間 Cursor 會Generate code 並提示創建 subfolder 或要確認及按 Accept / Accept all 去接受 AI 建議修改的內容



10. 在 Cursor 的 chat 窗口內再加入 Prompt 提示去逐步優化/修改項目如下
  1. Please replace the ContentView with HomeView and to provide mock data for the preview.
複製代碼
  1. Please make both HomeView and StockDetailView look visually nice and pretty and provide mock data to StockDetailView.
複製代碼
11. 最後切換到 XCode 內看 iPhone Simulator 的最後成果。




根據 AI Model 的提示,此 iOS app 可以再進一步優化
但在進一步優化前,強烈建議用XCode 進行 git Commit Changes
To make this a production app, you would need to:
  • Replace the mock data in StockService with real API calls
  • Add error handling and retry logic
  • Implement real-time price updates
  • Add more features like watchlists and search
  • Add unit tests and UI tests
  • Implement proper error views
  • Add more chart options and time ranges
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

本帖最後由 javacomhk 於 2025-4-26 05:25 編輯

Cursor AI 收費一的都唔平,每月付費20美元也只有500次高級模型的快速 API 請求,不過網上也有免付費版本,但只是較舊版本,有興趣的請參考這網址
https://github.com/yuaotian/go-cursor-help

另外一個免費的代替工具就是用國產(字节跳动的编程神器) Trae 的國際版本 https://www.trae.ai/home
不過免費的代價是多人用的 Model 繁忙時間就要排隊等候


Trae 都可以有 project rules 在 Settings 的 Rules 下
而 Add docs 就在 Settings 的 Context 下
國際版的 Model 選擇有以下,但是沒有 Auto 的選項



Apple Xcode AI 嘅 Swift Assist 都應該會在今年 WWDC 2025 出啦掛,到時先決定用邊隻抵的。
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP