用Claude Code開發iPhone App前必知嘅10大技巧!

Ai




10個我希望早知的用Claude Code開發iPhone應用程式的心得

用AI「vibe coding」聽起來輕鬆,實際做起來才發現點滴細節的重要性。透過Claude Code打造完整iPhone應用程式,讓我明白了逐步開發、備份和測試的重要。

這不是我第一次用AI一起編程。之前我用OpenAI的Codex成功為WordPress外掛新增模組,但這次用Claude Code從零開始寫一個複雜的iPhone應用,挑戰更大。

我這個App是用來管理Fab Lab內3D打印機的耗材線材,能追蹤超過100個線軸,涵蓋20個架子、8台機器和多個工作台。操作流暢,用手機輕輕一碰就能更新線軸位置。

以下是我在兩星期密集開發期間,從Claude Code學到的10個重要教訓,絕大部分技巧不只適用蘋果生態,任何用Claude vibe coding都能借鏡。

1. 逐步編碼,勿一次餵完整規格
我強烈反對一次給AI一大疊20頁規格文件,讓它產生2萬行代碼。這樣不但難測試,還會出大問題。相反,我是一步一步餵Claude,例如先讓它讀NFC標籤,再寫標籤,接著拍照、刪除照片、儲存照片……每完成一小段就測試,確保功能正常。

2. 指示Claude做筆記
每次工作開始和結束,我都要求Claude把學到的東西和決策寫成.md格式的文件,建立一份詳細的項目文檔。這樣Claude下次能快速「讀懂」之前的進度,減少重新熟悉的時間。

3. 消除「回神」時間
我不是全職程序員,常常只有零碎時間寫程式。以前回來接手項目都要花很久重新理解。現在靠Claude紀錄,30分鐘就能重新上手,極大提升效率。

4. 「壓縮」提示就是該結束本次工作
Claude會在記憶容量快滿時自動壓縮資料,這時候我就知道要叫它存檔、結束會話,然後再開新會話繼續。

5. 利用GitHub做保險
即使是獨立開發者,我也建議一定要用GitHub管理版本。Claude能幫忙提交代碼,分支管理功能讓我能測試新功能,確定沒問題才合併。還要記得備份手機資料,防止AI誤操作造成損失。

6. 早點做資料匯入匯出功能
我的App資料量大,早期就建置匯入匯出功能,方便測試和資料備份。內部資料結構會變,還要讓AI幫忙寫資料遷移工具,確保舊資料能升級。

7. 調試要有策略
AI寫的代碼不會完美,特別是蘋果生態的細節很多。我讓Claude幫忙加內部日誌,並教它怎麼看日誌、找問題。我也會清楚告訴它用例和目標,讓AI更精準地協助debug。記住:測試永遠是人類的責任。

8. 整理檔案結構
Claude會亂放檔案,對人類來說亂七八糟很難管理。要定期請它整理目錄結構,並且測試調整後的代碼確保不出錯。別單靠AI,要自己檢查。

9. Claude不是老闆
有時Claude會變得「愛指揮」,叫你去做某些事而不是自己寫代碼。這時候要堅持讓它動手做,別被它「耍」了。

10. 使用Swift和SwiftUI
蘋果官方的Swift語言和SwiftUI框架是開發iOS App的首選。用這些工具開發的程式碼將來可輕鬆移植到Mac或Apple Watch,保持原生體驗。

我的評論與啟示

這篇分享展現了AI輔助編程的「實戰真相」:AI不是魔法盒子,一味放大規模反而會帶來混亂。逐步小心試錯、持續記錄、善用版本控制和備份,才是成功關鍵。這也提醒我們,即使有AI,工程師的規劃能力、問題分析和測試能力依然不可或缺。

尤其是Claude會「自我壓縮」的設計,反映了當前AI模型在記憶和上下文管理上的限制。這種「提醒」機制其實是AI輔助開發流程中一個重要的節奏點,讓開發者知道何時該保存、結束,避免資料丟失。

另外,AI有時會「當老闆」的行為,顯示出目前AI的「自主性」還很有限,仍需人類堅持「主導權」,這是一個值得深思的現象。

最後,作者強調Swift和SwiftUI的重要性,提醒開發者在AI浪潮中仍應該紮實掌握平台原生工具,這樣才能兼顧效率與擴展性。這對香港及華語圈開發者來說,也是值得借鑒的技術規劃方向。

總結來說,這篇文章不只是AI編程技巧,更是一堂如何與AI共事、發揮最大效益的實務課。AI是強大助手,但真正的掌控與決策權,仍在於人類開發者手中。面對AI編程的未來,保持謹慎、系統化和人機協同的心態,會是成功的關鍵。

以上文章由特價GPT API KEY所翻譯及撰寫。而圖片則由FLUX根據內容自動生成。

🎨 Nano Banana Pro 圖像生成器|打幾句說話就出圖

想畫人像、產品圖、插畫?SSFuture 圖像生成器支援 Flux Gemini Nano Banana Pro 改圖 / 合成, 打廣東話都得,仲可以沿用上一張圖繼續微調。

🆓 Flux 模型即玩,不用登入
🤖 登入後解鎖 Gemini 改圖
📷 支援上載參考圖再生成
⚡ 每天免費額度任你玩
✨ 即刻玩 AI 畫圖
A close-up of a young man (as in the uploaded image) Dominates the right side of the frame, viewed from a low-angle perspective, giving him a powerful and imposing presence. He is wearing a simple white tank top (muscle shirt) and tan or light-yellow cargo shorts. He is holding a wooden baseball bat slung over his right shoulder. His expression is serious and determined.

JustinE the Rottweiler: Located on the left, chained to man. JustinE is in an aggressive stance, mouth wide open in a fierce snarl or bark, showing his teeth and tongue, with saliva visible. He is wearing a thick, heavy silver chain leash and collar, with a small circular dog tag visible that says "JustinE". The dog is large and muscular, facing the viewer.

Leash: A heavy-gauge silver metal chain connects JustinE's collar to man's hand.

Lighting: Strong, harsh daylight typical of Southern California, creating deep shadows and high contrast, enhancing the dramatic feel.

Background/Setting: A Southern San Andreas (Los Santos) street setting. The background is slightly blurred but suggests a hot, dry, urban environment with power lines/telegraph wires and a glimpse of an older vehicle (possibly a green van) in the lower-left corner. The sky is a bright, clear, light yellow-green color, indicative of a hot day.

hard shadows, and a distinct color palette typical of GTA loading screens and cover.

Highly detailed and rendered. Vibrant, cinematic. Use the original face exactly as it is, without changing a details. A stunning, highly detailed portrait of a beautiful young woman styled in a classic 1940s/1950s pin-up/rockabilly aesthetic.
👩 Character Details
• Expression: Confident, warm, and inviting smile with a direct gaze toward the viewer.
• Makeup: Flawless skin, bold red lipstick, defined eyebrows, classic winged black eyeliner, and a subtle rosy blush.
• Hair: Dark brown, perfectly styled into voluminous, glossy victory rolls and soft, structured waves.
• Accessories: A small red and white polka-dot bow tied into her hair, a simple, elegant strand of pearl beads around her neck, and delicate dangle pearl earrings.
👗 Outfit
• A sleeveless, low-cut red dress with a white polka-dot pattern. The neckline features white trim (or a white inset) and a ruffled edge along the shoulders/bodice. The white trim is visible in the cleavage area.
📍 Setting & Environment
• Location: An indoor setting resembling a classic American diner or café with a retro ambiance.
• Background: The background is slightly blurred (shallow depth of field), featuring deep red booth seating and white/grey counter areas and subtle gold/brass accents. Other patrons are indistinctly visible in the background.
• Foreground: The woman is seated at a table or counter, leaning slightly forward with her chin resting on her hand. A white coffee cup and saucer is visible in the lower left corner.
🎨 Style & Quality
• Lighting: Soft, flattering, warm studio lighting that highlights her features and the glossy texture of her hair.
• Art Style: Hyper-realistic, high-resolution digital painting or photography, with sharp focus on the woman.
• Composition: Close-up to mid-torso portrait shot. A dynamic, ultra-realistic action shot of a snowboarder performing a high-air jump on a snowy mountain slope. The rider wears a bright green winter jacket, black snow pants, gloves, and a dark beanie, with reflective goggles catching the cold mountain light. A cloud of visible breath escapes from the rider’s mouth in the freezing air. Snow explodes upward from the snowboard, creating sharp, frozen particles suspended mid-air. The background features a dramatic high-altitude landscape with forested slopes and distant mountains under soft, cold blue lighting. Capture cinematic contrast, DSLR realism, 85mm lens, f/2.8, crisp details, slow-motion energy, dynamic composition, atmospheric depth, high-clarity sports photography.