Back to Prompts

Swift / iOS Development

CLAUDE.md for Swift and iOS/macOS projects with SwiftUI patterns

swiftiosmacosswiftuimobile
By Claude Code Community

CLAUDE.md Content

# Swift / iOS Project

This is a Swift project for Apple platforms using modern Swift patterns.

## Project Structure
- `Sources/` - Main application source code
- `Views/` - SwiftUI views
- `Models/` - Data models and entities
- `ViewModels/` - Observable view models
- `Services/` - Networking and business logic
- `Extensions/` - Swift extensions
- `Tests/` - Unit and UI tests

## Code Style
- Follow Swift API Design Guidelines
- Use SwiftUI for new views, UIKit only when necessary
- Prefer value types (structs/enums) over reference types (classes)
- Use Swift concurrency (async/await) for asynchronous code

## Conventions
- Use PascalCase for types, camelCase for properties and methods
- Use `@Observable` macro for view models (Swift 5.9+)
- Use `@Environment` and `@Binding` for data flow
- Prefer protocol-oriented programming
- Use Swift Package Manager for dependencies

## Error Handling
- Use typed throws where appropriate
- Define domain-specific error enums
- Use Result type for completion handlers
- Handle optionals safely with guard and if-let

## Architecture
- MVVM pattern with SwiftUI
- Dependency injection via environment
- Separate networking into service layers
- Use Combine or AsyncSequence for reactive streams

## Commands
- `swift build` - Build the project
- `swift test` - Run tests
- `xcodebuild -scheme App test` - Run Xcode tests

How to use

  1. Copy the content above
  2. Create a CLAUDE.md file in your project root
  3. Paste the content and customize as needed
  4. Claude Code will automatically use this context