
SnapKit
A Swift library that makes writing iOS and macOS Auto Layout constraints shorter and easier to read.
- Stars
- 20.3k
- Forks
- 2k
- Licence
- MIT
- Language
- Swift
- Last update
- 4 months ago
- Type
- Library
What it is
SnapKit is a Swift library for building app screen layouts with Apple's Auto Layout system. Instead of writing long, verbose constraint code, you describe positions and sizes in a short, chained syntax. It is aimed at developers building iOS, macOS, or tvOS apps.
- Position a view at the center of its parent with a single make.center.equalTo call
- Set width and height of a view in one line, such as make.width.height.equalTo(50)
- Create and manage layout constraints inside a view controller's viewDidLoad method
Great for
- Swift developers building UIKit or AppKit interfaces in code rather than Interface Builder
- Teams who want more readable Auto Layout code
- Developers maintaining an existing project that already uses SnapKit
Not ideal for
- Developers who build their interfaces visually in Storyboards or SwiftUI, since the README only covers code-based Auto Layout
- Projects that must run on older OS or Xcode versions than the README's stated requirements, because it requires iOS 14.0+, macOS 12.0+, tvOS 14.0+, Xcode 26.0+ and Swift 6.0+
How to get it
- 1
Install with a package manager
You'll need: Xcode 26.0+ · Swift 6.0+
Add SnapKit to Package.swift dependencies
.package(url: "https://github.com/SnapKit/SnapKit.git", .upToNextMajor(from: "6.0.0")) - 2
Run it
- Add the SnapKit package dependency to your project using Swift Package Manager
- Add import SnapKit at the top of a Swift file
- Call addSubview on your view, then use snp.makeConstraints to set its layout
- Build and run the app to see the result
- 3
Get the most out of it
- Read the official documentation at snapkit.github.io/SnapKit/docs/ for the full set of constraint methods
- Check the FAQ at snapkit.github.io/SnapKit/faq/ when you hit common questions
- Use the migration guides linked in the README when upgrading between major versions
Downloads
Strengths
- Short, chainable syntax compared with raw Auto Layout constraint code
- Released under the permissive MIT license
- Includes an online documentation site and FAQ linked from the README
Trade-offs
- Requires recent toolchains (Xcode 26.0+, Swift 6.0+), which may not suit older projects
- The README is brief and focuses on installation and one example, so advanced usage must be learned from the external docs
- Only supports Apple platforms
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| SnapKit (this) | 20.3k | Library | intermediate | 4 months ago | Swift developers building UIKit or AppKit interfaces in code rather than Interface Builder |
| Masonry | 18.1k | Library | intermediate | 3.6 years ago | iOS or macOS developers writing Objective-C projects that use Auto Layout in code |
| SwifterSwift | 15.3k | Library | beginner | 4 days ago | Swift developers building iOS or macOS apps who want common helper methods ready to use |
| NVActivityIndicatorView | 10.7k | Library | beginner | 8 months ago | iOS developers who want a ready-made loading indicator with many styles |
| folding-cell | 10.2k | Library | intermediate | 2.5 years ago | iOS developers building list screens with expandable items |
| SDWebImage | 25.6k | Library | intermediate | 7 months ago | iOS or macOS app developers who need to show remote images in lists or grids |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.