Rule

0 installs · 0 said it worked

PatrickJS@patrickjs·
CodingRule· for Cursor

Cursor rules enforcing UIKit programmatic UI and MVC separation

Cursor rule file that guides Swift/UIKit code generation: SnapKit auto layout, no Storyboards or XIBs, factory-based view creation so UI components never touch models, and closure-based events passing self.

People use this for

  • swiftui uikit cursor rules
  • uikit snapkit programmatic layout
  • swift mvc view factory pattern
  • ios closure event passing self
  • no storyboard uikit code generation
Name
cursor-rules-enforcing-uikit-programmatic-ui-and-mvc-separation
Works with
Cursor
License
CC0(as observed at the source)
Version
v1 · updated Nov 29, 2026
Imported · UnclaimedCC0

Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.

Are you the author?Claim this profileRequest removal

Use this rule

$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/cursor-rules-enforcing-uikit-programmatic-ui-and-mvc-separation-327y/export/mdc" -o .cursor/rules/cursor-rules-enforcing-uikit-programmatic-ui-and-mvc-separation.mdc

Then open a new session; Cursor picks it up from .cursor/rules/.

Download cursor-rules-enforcing-uikit-programmatic-ui-and-mvc-separation.mdc
Manual install

Save cursor-rules-enforcing-uikit-programmatic-ui-and-mvc-separation.mdc as .cursor/rules/cursor-rules-enforcing-uikit-programmatic-ui-and-mvc-separation.mdc for this project or ~/.cursor/rules/cursor-rules-enforcing-uikit-programmatic-ui-and-mvc-separation.mdc for every project, then start a new session.

Rule


description: "Cursor rules for UIKit development guidelines." globs: */ alwaysApply: false

you are an expert in coding with swift, iOS, UIKit. you always write maintainable code and clean code. focus on latest documentation and features. your descriptions should be short and concise. don't remove any comments.

UIKit UI Design Principles:

  1. Auto Layout: Implement responsive layouts using SnapKit only (avoid NSLayoutConstraint for better readability), support Dynamic Type and Safe Area
  2. Programmatic UI: Avoid Storyboards/XIBs, implement all UI components directly in code (UIView, UIButton, UITableViewCell). Use view composition and custom view subclasses for reusability
  3. UI Components must not directly access models or DTOs. Use ViewController, Factory, or Builder patterns following OOP/MVC/MVVM principles. Below are good and bad practice examples:

good practice:

let user = User(name: "Alice", email: "john@example.com")
let factory = UserFactory()
/// This way UserView doesn't access User model directly, following Apple's MVC principles
let userView = factory.createUserView(user: user)

bad practice:

let user = User(name: "Alice", email: "john@example.com")
/// This exposes UserView to User model, violating MVC principles
let userView = UserView(user: user)
  1. UI components should pass events using closures, and the closure must pass 'self' as a parameter to allow external objects to identify the source component
class SampleView: UIView {
    var didTapButton: ((SampleView) -> Void)?
    private let button = UIButton()
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
        button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
    }

    private func setupUI() {
        // setup UI
    }

    @objc private func buttonTapped() {
        didTapButton?(self)
    }
}

No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.

Tried it

Reports from people who added this rule to their editor. They roll up into the badges above.

No one has filed a report yet. Try the prompt and be the first.

License: CC0v1 · published Nov 29, 2026

Comments

No comments yet. If you tried this prompt, say how it went.