Home › Swift / SwiftUI › SwiftUI iOS app CLAUDE.md

SwiftUI iOS app CLAUDE.md

CLAUDE.md for SwiftUI apps on iOS 18+ with Swift 6 strict concurrency, @Observable, SwiftData, and Swift Testing.

Claude Code (CLAUDE.md)Swift / SwiftUI

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

CLAUDE.mdDownload  
# CLAUDE.md: SwiftUI app (Swift 6)

## Build & test
- `xcodebuild -scheme App -destination 'platform=iOS Simulator,name=iPhone 16' build test`
- Format/lint with `swift format` / SwiftLint if configured.

## Conventions
- Swift 6 language mode with strict concurrency. Fix data-race errors properly (actors, `Sendable`, `@MainActor`); don't silence them with `@unchecked Sendable` or `nonisolated(unsafe)`.
- UI state with the Observation framework: `@Observable` classes, `@State` for owned models, `@Bindable` for bindings, `@Environment` for shared ones. No new `ObservableObject`/`@Published`.
- Views stay small; extract subviews instead of long `body`s. Previews with `#Preview` for every view.
- Navigation with `NavigationStack` and typed `navigationDestination(for:)`.
- Async work with `async/await` and `.task {}` modifiers (auto-cancelled). No completion handlers in new code; no `DispatchQueue.main.async` in SwiftUI code.
- Persistence with SwiftData (`@Model`, `@Query`) if the project uses it; otherwise follow the existing store.
- Networking through one `APIClient` using `URLSession` + `Codable`.
- Accessibility: labels on icon-only buttons, support Dynamic Type, no fixed font sizes.

## Tests
Swift Testing (`import Testing`, `@Test`, `#expect`) for new tests.

## Don't
Don't force unwrap (`!`) outside tests, or edit the `.pbxproj` by hand when a Swift package or file can be added via the project's tooling.

More: all Swift / SwiftUI rules · all Claude Code (CLAUDE.md) rules

Related rules

Kotlin Multiplatform + Compose Multiplatform CLAUDE.md

CLAUDE.md for Kotlin Multiplatform apps sharing UI with Compose Multiplatform across Android, iOS, desktop, and web.

Claude Code (CLAUDE.md)Kotlin Multiplatform

.NET MAUI rules

Cursor rules for .NET MAUI apps on .NET 10: MVVM with CommunityToolkit.Mvvm, Shell navigation, compiled bindings, DI.

Cursor.NET MAUI

Flutter AGENTS.md

AGENTS.md for Flutter apps with Riverpod, go_router and clean feature-first structure.

AGENTS.mdFlutter

Flutter + Riverpod rules

Cursor rules for Flutter 3 apps using Riverpod 3 with code generation, go_router, and widget tests.

CursorFlutter

Ionic + Capacitor AGENTS.md

AGENTS.md for Ionic 8 apps with Capacitor (Angular, React, or Vue): native plugins, platform sync, and mobile UX rules.

AGENTS.mdIonic / Capacitor

Kotlin Multiplatform Copilot path instructions

Path-specific Copilot instructions for Kotlin Multiplatform modules: commonMain first, expect/actual, and coroutines.

GitHub CopilotKotlin Multiplatform

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.