claude-code-ios-dev-guide
keskinonur · keskinonur/claude-code-ios-dev-guide
Một hướng dẫn toàn diện để cấu hình Claude Code CLI cho phát triển iOS, cho phép quy trình làm việc dựa trên PRD, tư duy mở rộng và chế độ lập kế hoạch tối ưu cho Swift/SwiftUI.
Hướng dẫn toàn diện để thiết lập Claude Code CLI với các quy trình làm việc theo định hướng PRD, tư duy mở rộng (ultrathink) và các chế độ lập kế hoạch được tối ưu hóa cho phát triển iOS bằng Swift/SwiftUI.
Xem trước
Bạn có thể làm gì với nó
- Thiết lập môi trường Claude Code đặc biệt để xây dựng ứng dụng iOS.
- Triển khai quy trình phát triển dựa trên PRD với sự hỗ trợ của AI cho các dự án Swift.
- Cấu hình các lệnh slash tùy chỉnh và kỹ năng tác nhân cho các tác vụ cụ thể của iOS.
Kiểm tra an toàn
Dùng được, nhưng nên đọc ghi chú trước.
- ●Trình cài đặt tải script từ xa và chạy thẳng bằng shell.
README.md - ●Không có giấy phép rõ ràng: hỏi tác giả trước khi dùng cho sản phẩm thương mại.
Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.
Trích từ README
Claude Code CLI - Complete iOS Development Setup Guide
A comprehensive guide for setting up Claude Code CLI with PRD-driven workflows, extended thinking (ultrathink), and planning modes optimized for Swift/SwiftUI iOS development.
Table of Contents
- Installation
- Configuration Hierarchy
- CLAUDE.md Setup for iOS Projects
- PRD-Driven Development Workflow
- Extended Thinking & Ultrathink
- Plan Mode Configuration
- XcodeBuildMCP Integration
- Custom Slash Commands for iOS
- Agent Skills
- Subagents Configuration
- Output Styles
- Plugins System
- Sandbox Mode & Safe Development
- Settings & Permissions
- Hooks for Swift Development
- Complete Project Structure
- Best Practices & Tips
1. Installation
Native Installation (Recommended)
# macOS/Linux - Native installer (no Node.js required)
curl -fsSL https://claude.ai/install.sh | bash
# Or install latest version
curl -fsSL https://claude.ai/install.sh | bash -s latest
NPM Installation (Alternative)
# Global npm install (do NOT use sudo)
npm install -g @anthropic-ai/claude-code
# Migrate existing npm install to native
claude install
Authentication
# Start Claude Code and authenticate via OAuth
claude
# Or set API key environment variable
export ANTHROPIC_API_KEY="your-key-here"
Model Selection
# Use specific model at startup
claude --model claude-opus-4-5-20250929
claude --model claude-sonnet-4-5-20250929
claude --model claude-3-5-haiku-20241022
# Or set default model
export ANTHROPIC_MODEL="claude-sonnet-4-5-20250929"
2. Configuration Hierarchy
Claude Code uses a layered configuration system where each level can override the one below:
Priority (Highest to Lowest):
├── 1. Session flags (--model, --permission-mode)
├── 2. Environment variables
├── 3. .claude/settings.local.json (local - personal, gitignored)
├── 4. .claude/settings.json (project - shared with team)
└── 5. ~/.claude/settings.json (user - global)
Configuration Scopes
| Scope | Description | Storage |
|---|---|---|
| local | Available only to you in current project (default for MCP) | .claude/settings.local.json |
| project | Shared with team via git | .claude/settings.json, .mcp.json |
| user | Available across all your projects | ~/.claude/settings.json |
Key Configuration Files
| File | Scope | Git Status | Purpose |
|---|---|---|---|
~/.claude/settings.json | User | N/A | Global preferences |
~/.claude/CLAUDE.md | User | N/A | Global instructions |
~/.claude/skills/ | User | N/A | Personal Agent Skills |
~/.claude/commands/ | User | N/A | Personal slash commands |
.claude/settings.json | Project | Committed | Team settings |
.claude/settings.local.json | Local | Gitignored | Personal overrides |
.mcp.json | Project | Committed | Shared MCP servers |
CLAUDE.md | Project | Committed | Main project context |
.claude/skills/ | Project | Committed | Project Agent Skills |
.claude/commands/ | Project | Committed | Project slash commands |
.claude/agents/ | Project | Committed | Project subagents |
3. CLAUDE.md Setup for iOS Projects
The CLAUDE.md file is your primary context provider. Claude automatically loads it at session start.
Root CLAUDE.md Template for iOS
Create CLAUDE.md in your project root:
# Project: [Your App Name]
## Quick Reference
- **Platform**: iOS 17+ / macOS 14+
- **Language**: Swift 6.0
- **UI Framework**: SwiftUI
- **Architecture**: MVVM with @Observable
- **Minimum Deployment**: iOS 17.0
- **Package Manager**: Swift Package Manager
## XcodeBuildMCP Integration
**IMPORTANT**: This project uses XcodeBuildMCP for all Xcode operations.
- Build: `mcp__xcodebuildmcp__build_sim_name_proj`
- Test: `mcp__xcodebuildmcp__test_sim_name_proj`
- Clean: `mcp__xcodebuildmcp__clean`
## Project Structure
MyApp/ ├── App/ # App entry point, App delegate ├── Features/ # Feature modules │ ├── [FeatureName]/ │ │ ├── Views/ # SwiftUI views │ │ ├── ViewModels/ # @Observable classes │ │ └── Models/ # Data models ├── Core/ # Shared utilities │ ├── Extensions/ │ ├── Services/ │ └── Networking/ ├── Resources/ # Assets, Localizations └── Tests/
## Coding Standards
### Swift Style
- Use Swift 6 strict concurrency
- Prefer `@Observable` over `ObservableObject`
- Use `async/await` for all async operations
- Follow Apple's Swift API Design Guidelines
- Use `guard` for early exits
- Prefer value types (structs) over reference types (classes)
### SwiftUI Patterns
- Extract views when they exceed 100 lines
- Use `@State` for local view state only
- Use `@Environment` for dependency injection
- Prefer `NavigationStack` over deprecated `NavigationView`
- Use `@Bindable` for bindings to @Observable objects
### Navigation Pattern
```swift
// Use NavigationStack with type-safe routing
enum Route: Hashable {
case detail(Item)
case settings
}
NavigationStack(path: $router.path) {
ContentView()
.navigationDestination(for: Route.self) { route in
// Handle routing
}
}
Error Handling
// Always use typed errors
enum AppError: LocalizedError {
case networkError(underlying: Error)
case validationError(message: String)