Installation
Masonry supports multiple installation methods. Choose the one that best fits your project.
Swift Package Manager (Recommended)
Add Masonry to your Package.swift:
dependencies: [
.package(url: "https://github.com/AmatsuZero/Masonry.git", from: "1.3.4")
]
Two library products are available:
| Product | Description |
|---|---|
Masonry | Objective-C core module |
MasonrySwift | Swift native DSL (depends on Masonry) |
Add the desired product to your target's dependencies:
.target(
name: "YourApp",
dependencies: [
.product(name: "MasonrySwift", package: "Masonry"),
]
)
Tips
If you only need the Objective-C API, use Masonry as the product name instead.
CocoaPods
Add to your Podfile:
# Objective-C only
pod 'Masonry'
# Objective-C + Swift DSL
pod 'Masonry/Swift'
Then run:
pod install
Carthage
Add to your Cartfile:
github "AmatsuZero/Masonry"
Then run:
carthage update --use-xcframeworks
Manual Integration
- Clone or download the repository
- Drag the
Masonryfolder into your Xcode project - Ensure the source files are added to your target's Compile Sources build phase
Privacy Manifest
Starting with v1.3.2, Masonry ships with an Apple Privacy Manifest (PrivacyInfo.xcprivacy). The manifest declares that Masonry:
- Does not collect any data
- Does not use any required-reason APIs
- Does not track users
Both SPM and CocoaPods integrate the manifest automatically — no extra configuration is needed.
Xcode Code Snippets
The repository includes ready-to-use Xcode code snippets in the CodeSnippets/ directory. Copy them to enable quick autocompletion:
cp CodeSnippets/* ~/Library/Developer/Xcode/UserData/CodeSnippets/
Available snippets:
| Shortcut | Language | Description |
|---|---|---|
mas_make | Objective-C | mas_makeConstraints block |
mas_update | Objective-C | mas_updateConstraints block |
mas_remake | Objective-C | mas_remakeConstraints block |
mas_swift_make | Swift | mas.makeConstraints closure |
mas_swift_update | Swift | mas.updateConstraints closure |
mas_swift_remake | Swift | mas.remakeConstraints closure |