uikit

UIKit imperative iOS UI framework. Use for iOS development.

7 stars

Best use case

uikit is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

UIKit imperative iOS UI framework. Use for iOS development.

Teams using uikit should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/uikit/SKILL.md --create-dirs "https://raw.githubusercontent.com/G1Joshi/Agent-Skills/main/skills/mobile/uikit/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/uikit/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How uikit Compares

Feature / AgentuikitStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

UIKit imperative iOS UI framework. Use for iOS development.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# UIKit

UIKit is the traditional, imperative framework for building iOS user interfaces. While SwiftUI is the future, UIKit remains essential for maintaining existing apps and unrestricted access to the OS.

## When to Use

- Maintaining legacy iOS codebases (Objective-C or Swift).
- Fine-grained control over view hierarchy performance not yet possible in SwiftUI.
- Using third-party libraries that haven't migrated to SwiftUI ViewRepresentables.

## Quick Start

```swift
// Programmatic UIKit (No Storyboards) in SceneDelegate
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
    guard let windowScene = (scene as? UIWindowScene) else { return }
    window = UIWindow(windowScene: windowScene)
    window?.rootViewController = UINavigationController(rootViewController: HomeViewController())
    window?.makeKeyAndVisible()
}

class HomeViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .systemBackground
        title = "UIKit Home"

        let button = UIButton(type: .system)
        button.setTitle("Tap Me", for: .normal)
        button.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(button)

        NSLayoutConstraint.activate([
            button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            button.centerYAnchor.constraint(equalTo: view.centerYAnchor)
        ])
    }
}
```

## Core Concepts

### View Controller Lifecycle

Understanding `viewDidLoad`, `viewWillAppear`, `viewDidLayoutSubviews` is critical for managing state and layout updates correctly in the imperative model.

### Auto Layout

The layout engine based on constraints. Use `NSLayoutConstraint` or library wrappers (SnapKit) to define rules (e.g., "A is 10px below B").

### Delegates & Data Sources

Common pattern for handling events (UITableViewDelegate) and providing data (UITableViewDataSource).

## Common Patterns

### Diffable Data Source

Modern replacement for `reloadData()`.

- Uses `NSDiffableDataSourceSnapshot` to animate changes automatically and safely.
- eliminates "Index out of range" crashes during updates.

### Compositional Layout

Modern API for building complex collection view layouts (grids, carousels) without subclassing `UICollectionViewLayout`.

### Coordinator Pattern

Moving navigation logic out of ViewControllers to improve reusability and testing.

## Best Practices

**Do**:

- Use **Diffable Data Sources** for Lists and Collections.
- Use **Compositional Layouts** instead of FlowLayouts.
- Use **View Binding** mechanisms (like Combine) to update UI, rather than manually setting properties everywhere.

**Don't**:

- Don't use massive Storyboards (merge conflicts hell).
- Don't force `layoutIfNeeded()` unless animating changes.
- Don't forget `[weak self]` in closures to avoid memory leaks (Retain Cycles).

## Troubleshooting

| Error                       | Cause                          | Solution                                                                   |
| :-------------------------- | :----------------------------- | :------------------------------------------------------------------------- |
| `Unsatisfiable Constraints` | Conflicting Auto Layout rules. | Check console log for breaking constraint IDs; simplify rules.             |
| `TableView Updates Crash`   | Inconsistent data vs rows.     | Use Diffable Data Source or ensure data model updates before `insertRows`. |
| `Retain Cycle`              | Strong reference loop.         | Use Memory Graph Debugger; verify `[weak self]`.                           |

## References

- [Apple UIKit Documentation](https://developer.apple.com/documentation/uikit)
- [Modern UIKit Patterns](https://developer.apple.com/videos/play/wwdc2020/10097/)