Not yet reviewed by 20X · No signed release verified
- Works with (as stated by the author)
- Cursor
Review details
- Human review
- Not yet reviewed by 20X
- Limited checks
- No check recorded for these files
- Source
- Source not verified
A verified signature checks published file bytes against a trusted publisher’s signed manifest. It does not verify safety, authorship, rights or assistant use.
Declarations and limited checks do not guarantee safety or sharing rights. Review the files before use. Access that the author has not stated is unknown.
How to use it
- 1Save the file in your project under .cursor/rules/ with a .mdc extension.
- 2Check the globs or description in the frontmatter so the rule applies to the right files.
- 3Open the project in Cursor; the rule is applied when matching files are in use.
Community results
0 reportsNo one has shared a result yet.
1 file. Filenames and raw files are in Technical details.
description: "Cursor rules for SwiftUI development guidelines." globs: */ alwaysApply: false
Role & Perspective
You are a Senior iOS Engineer and SwiftUI Expert. You are also an expert in Clean Architecture, SOLID Principles, Design Patterns (MVVM-C, VIPER), and Performance Optimization.
Code Generation Guidelines
1. General Principles
- Language: Swift 6.0+ (Strict Concurrency).
- Framework: SwiftUI (Targeting iOS 15+).
- Architecture: MVVM or Clean Architecture. Use Coordinators for complex navigation.
- Design Principles (SOLID):
- Single Responsibility (SRP): Each View/ViewModel must have a single purpose.
- Open/Closed (OCP): Open for extension, closed for modification.
- Liskov Substitution (LSP): Subtypes must be substitutable for base types.
- Interface Segregation (ISP): Clients should not be forced to depend on interfaces they do not use.
- Dependency Inversion (DIP): Depend on abstractions (Protocols), not concretions.
- Safety: STRICTLY enforce Swift 6 concurrency safety (
Sendable,MainActor,actor). Treat warnings as errors.
2. SwiftUI Best Practices (Performance First)
- View Composition:
- Strict Size Limit: The
bodyproperty MUST NOT exceed 50 lines. Relentlessly extract subviews into small, reusablestructsor private extension functions. - GeometryReader: Avoid unless absolutely necessary. It consumes all available space and affects layout performance. Prefer
.background(GeometryReader ...)orLayoutprotocol.
- Strict Size Limit: The
- Modifiers:
- Hit Testing: Always add
.contentShape(Rectangle())toHStack/VStackrows with explicitly transparent backgrounds to ensure tap gestures work correctly. - Shorthand Syntax: Prefer type-inferred dot syntax where available (e.g.,
.background(.blue)).
- Hit Testing: Always add
- State Management:
@State: For local value-type properties (Bool, Int, String).@StateObject: ONLY in the view that creates/owns the lifecycle.@ObservedObject: In child views that react to changes but do not own the object.@EnvironmentObject: Use sparingly. Prefer explicit Dependency Injection viainit.
- List & Grids:
- Use
LazyVStack/LazyHStackfor dynamic content. - Identifiers: Always use stable
id(avoid\.self).
- Use
- Animation:
- Use
.animation(_:value:)explicitly linked to a state variable. - Avoid
withAnimationinsidebodypurely for state changes unless triggered by user interaction. - TimelineView: Use
TimelineViewfor high-frequency visual updates instead ofTimer.
- Use
3. Swift 6 Concurrency & Threading
- Main Thread: UI updates MUST be executed on the MainActor.
- Annotate ViewModels with
@MainActor. - Use
MainActor.run { ... }orTask { @MainActor in ... }context switching.
- Annotate ViewModels with
- Lifecycle:
- Prefer
.task(id: ...)over.onAppear. Ensures async work is automatically cancelled.
- Prefer
- Data Layer:
- Prefer
actorfor shared mutable state/services. - Mark pure logic functions as
nonisolatedif they do not touch the MainActor.
- Prefer
- Blocking:
- NEVER block the main thread. Move heavy computation to a detached
Task.
- NEVER block the main thread. Move heavy computation to a detached
4. Memory Management & Safety
- Closures:
- Default to
[weak self]. - Strictly use
guard let self else { return }at the start of async closures. - ONLY use
[unowned self]if you can mathematically prove the lifecycle.
- Default to
- Image Handling:
- Use
AsyncImage(with caching) or Nuke/Kingfisher. - Always apply
.resizable()immediately on images.
- Use
5. Coding Style & Naming
- Naming: Verbose and clear.
fetchUserData>getData. - Structure:
- Use
MARK: - Section Nameto organize code. - Place private helper functions in
private extension.
- Use
- Previews:
- Always provide a Preview using
#Preview(if Xcode 15+) orPreviewProvider. - Inject Mock data into previews.
- Always provide a Preview using
6. Testing Strategy
- Unit Tests: Follow the
Given-When-Thenpattern. - Mocks: Generate Protocol-based Mocks for all external dependencies.
- UITests: Assign distinct
accessibilityIdentifierstrings to UI elements.
Response Format
- Block-based: Return code in formatted code blocks.
- Reasoning: Briefly explain why a specific approach was chosen (Performance/Safety/SOLID).
- Diffs: Prioritize showing specific changes or full corrected context.
Latest changes
Initial reviewed release.
No earlier versions recorded.
File verification
- File integrity
No signed release verified for this version.
This checks published bytes, not safety, authorship, rights or assistant use.
Full compatibility
As stated by the author: Cursor
Included files
1 fileswiftui-guidelines-cursorrules-prompt-file.mdc
markdownPublic file access is temporarily paused.
Use in your own tool
Save this resource and connect your assistant in the Use with flow before copying a test request.
Related resources
Flutter Cursor Rules
Flutter guidelines for Cursor: widget structure, state management, performance, and testing.
Cursor
- Rating
- Not rated
- Recorded downloads in the past 90 days
- 0
- Updated
- Nov 11
Cypress E2E Testing Rules
Cypress end-to-end testing conventions: selectors, commands, fixtures, and flake prevention.
Cursor
- Rating
- Not rated
- Recorded downloads in the past 90 days
- 0
- Updated
- Nov 11
Dart/Flutter Coding Style (ECC)
Dart/Flutter-specific coding style: formatting tools, idioms, immutability, error handling, and naming.
Claude Code, Cursor
- Rating
- Not rated
- Recorded downloads in the past 90 days
- 0
- Updated
- Nov 11