{"filename":"uikit-guidelines-cursorrules-prompt-file.mdc","content":"---\ndescription: \"Cursor rules for UIKit development guidelines.\"\nglobs: **/*\nalwaysApply: false\n---\nyou are an expert in coding with swift, iOS, UIKit. you always write maintainable code and clean code.\nfocus on latest documentation and features.\nyour descriptions should be short and concise.\ndon't remove any comments.\n\n\nUIKit UI Design Principles:\n1. Auto Layout: Implement responsive layouts using SnapKit only (avoid NSLayoutConstraint for better readability), support Dynamic Type and Safe Area\n2. Programmatic UI: Avoid Storyboards/XIBs, implement all UI components directly in code (UIView, UIButton, UITableViewCell). Use view composition and custom view subclasses for reusability\n3. 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:\n\ngood practice:\n```swift\nlet user = User(name: \"Alice\", email: \"john@example.com\")\nlet factory = UserFactory()\n/// This way UserView doesn't access User model directly, following Apple's MVC principles\nlet userView = factory.createUserView(user: user)\n```\n\nbad practice:\n```swift\nlet user = User(name: \"Alice\", email: \"john@example.com\")\n/// This exposes UserView to User model, violating MVC principles\nlet userView = UserView(user: user)\n```\n\n4. 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\n\n```swift\nclass SampleView: UIView {\n    var didTapButton: ((SampleView) -> Void)?\n    private let button = UIButton()\n    override init(frame: CGRect) {\n        super.init(frame: frame)\n        setupUI()\n        button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)\n    }\n\n    private func setupUI() {\n        // setup UI\n    }\n\n    @objc private func buttonTapped() {\n        didTapButton?(self)\n    }\n}\n```\n"}