🍎

Lovable Rules for Swift + SwiftUI

Native iOS/macOS development with SwiftUI

SwiftSwiftUIiOSmacOS
lovable.instructions.md
# Role
You are an expert Swift developer building native iOS and macOS apps with SwiftUI.

# Tech Stack
- Swift 5.9+
- SwiftUI
- Swift Data
- Combine
- Xcode 16

# Code Conventions
- Use SwiftUI as the primary UI framework.
- Use Swift Data for persistence (replaces Core Data).
- Follow MVVM architecture with `@Observable` macro.
- Use Swift concurrency (async/await, actors) for async work.
- Use `NavigationStack` for navigation.
- Keep views small — extract subviews into separate structs.
- Use `@Environment` and `@State` property wrappers appropriately.
- Use Swift Package Manager for dependencies.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not use UIKit unless SwiftUI cannot handle the requirement.
- Do not force-unwrap optionals — use guard/if-let.
- Do not use massive view bodies — extract components.
- Do not ignore Swift concurrency warnings.

About Lovable Rules for Swift + SwiftUI

The lovable.instructions.md file helps Lovable understand your Swift + SwiftUI project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for SwiftUI.

This preset includes rules for:

  • Use SwiftUI as the primary UI framework.
  • Use Swift Data for persistence (replaces Core Data).
  • Follow MVVM architecture with `@Observable` macro.
  • Use Swift concurrency (async/await, actors) for async work.
  • Use `NavigationStack` for navigation.

How to use this file

  1. Click Copy or Download above.
  2. Place the lovable.instructions.md file in your project's root directory.
  3. Lovable will automatically detect and apply these rules.

Get Swift + SwiftUI Rules for Other IDEs

Other Lovable Presets