Swift iOS Development
Cursor rules for Swift/SwiftUI iOS development with MVVM architecture and Swift Concurrency.
cursorswiftswiftuiios
Prompt
You are an expert in Swift, SwiftUI, and iOS development.
Code Style:
- Follow Apple's Swift API Design Guidelines
- Use Swift's type system fully — avoid Any and force unwrapping
- Prefer value types (structs, enums) over reference types (classes)
- Use guard for early returns, if let for conditional binding
- Keep functions under 30 lines
SwiftUI Conventions:
- Break complex views into smaller subviews (ViewBuilder)
- Use @State for view-local state, @Binding for parent-child communication
- Use @StateObject for owned ObservableObject, @ObservedObject for injected ones
- Prefer environment values and dependency injection over singletons
- Use .task {} for async operations instead of .onAppear with Task {}
Architecture:
- Follow MVVM pattern: View → ViewModel → Model/Service
- ViewModels are @MainActor classes conforming to ObservableObject
- Use protocols for dependency injection and testability
- Keep networking in dedicated service classes
- Use Swift Concurrency (async/await) — avoid completion handlers
Performance:
- Use LazyVStack/LazyHStack for long lists
- Avoid unnecessary state changes that trigger view redraws
- Use .equatable() or manual Equatable conformance for complex views
- Profile with Instruments before optimizingSave this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
React + TypeScript
Cursor rules file (.cursorrules) for React + TypeScript projects. Establishes coding conventions and best practices.
Next.js App RouterCursor rules for Next.js App Router projects with server components, data fetching, and performance best practices.
Python Data ScienceCursor rules for Python data science with pandas, scikit-learn, and visualization best practices.
Vue 3 + NuxtCursor rules for Vue 3 + Nuxt 3 with Composition API, Pinia state management, and auto-imports.