explaingit

snapkit/masonry

Analysis updated 2026-05-18

18,166Objective-CAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Masonry simplifies iOS layout code by replacing verbose Auto Layout constraints with a clean, chainable syntax for positioning UI elements.

Mindmap

mindmap
  root((repo))
    What it does
      Simplifies layout code
      Chainable constraint API
      Handles Auto Layout
    Key features
      Position and size views
      Set spacing and padding
      Constraint priorities
      Autoresizing translation
    Use cases
      Build responsive iOS apps
      Create Mac OS X interfaces
      Reduce layout boilerplate
    Tech stack
      Objective-C
      iOS SDK
      Mac OS X SDK
    Distribution
      CocoaPods
      Carthage
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build responsive iOS apps that adapt to different screen sizes and orientations without writing verbose constraint code.

USE CASE 2

Create Mac OS X desktop applications with clean, readable layout definitions using chainable syntax.

USE CASE 3

Set up complex view hierarchies with spacing, padding, and alignment rules in fewer lines of code.

USE CASE 4

Define constraint priorities so some layout rules can be broken when screen space is limited.

What is it built with?

Objective-CiOS SDKMac OS X SDKCocoaPodsCarthage

How does it compare?

snapkit/masonrygnachman/iterm2realm/realm-swift
Stars18,16617,54716,601
LanguageObjective-CObjective-CObjective-C
Setup difficultyeasyeasyeasy
Complexity2/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
Use freely for any purpose including commercial, as long as you keep the copyright notice.

In plain English

Masonry is an Objective-C library for iOS and Mac OS X that simplifies the way developers define layout rules (called Auto Layout constraints) for user interface elements. Auto Layout is Apple's system for positioning views on screen in a way that adapts to different screen sizes and orientations. Normally, writing these constraints in code is very verbose, a single simple rule like "this view should fill its parent with 10 points of padding on each side" requires many lines of repetitive, hard-to-read code. Masonry provides a cleaner, chainable syntax for the same thing. Instead of constructing constraint objects manually, you use a block-based API where you describe relationships in a natural way, such as "make this view's edges equal to its superview's edges with insets." The library automatically attaches the constraints to the right views and handles the usual boilerplate of disabling autoresizing translation. It supports all standard layout attributes: position, size, centering, and spacing, as well as setting priorities so that some constraints can be broken when space is tight. The project recommends its Swift-language counterpart, SnapKit, for projects written in Swift, since Swift offers better type safety. Masonry itself remains actively maintained for Objective-C projects. It is available via CocoaPods and Carthage, the common iOS dependency managers.

Copy-paste prompts

Prompt 1
Show me how to use Masonry to make a view fill its parent with 10 points of padding on all sides.
Prompt 2
How do I center a view horizontally and vertically on its superview using Masonry's chainable syntax?
Prompt 3
Write a Masonry constraint that makes two views equal width and stacks them vertically with 20 points spacing.
Prompt 4
How do I set different constraint priorities in Masonry so some layout rules break when space is tight?
Prompt 5
Convert this verbose Auto Layout code to Masonry: [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10].

Frequently asked questions

What is masonry?

Masonry simplifies iOS layout code by replacing verbose Auto Layout constraints with a clean, chainable syntax for positioning UI elements.

What language is masonry written in?

Mainly Objective-C. The stack also includes Objective-C, iOS SDK, Mac OS X SDK.

What license does masonry use?

Use freely for any purpose including commercial, as long as you keep the copyright notice.

How hard is masonry to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is masonry for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub snapkit on gitmyhub

Verify against the repo before relying on details.