Snaps combines Dials and SnapKit to let you make changes to your autolayout constraints at runtime and then send them back to your code with just one button. It also lets you see the actual variable names from your code in the Dials constraint debugger.
Snaps works with Dials and SnapKit so you will have to add them to your project first.
Snaps is an unusual project in that it has an iOS component and a desktop component. As such, you can use Cocoapods or Carthage to fetch and version it, but you'll have to perform some additional manual steps afterward.
Add the following to your Podfile
:
pod 'Snaps', '~> 1.0'
Add the following to your Cartfile
:
github "aleffert/Snaps"
You can also just add Snaps as a submodule directly:
git submodule add Libraries/Snaps git@github.com:aleffert/snaps.git
Once you have the files downloaded, you will need to do the following:
-
Find
Snaps.xcodeproj
in the Finder and drag it into your project's workspace. -
Add
Snaps.framework
as a library dependency for your iOS app in the "Build Phases" section of the target settings. -
Still within "Build Phases", find a "Copy Files" build phase whose "Destination" is "Frameworks" (you needed to add this when setting up Dials).
-
Hit the "+" button and add "Snaps.framework" to your Copy Files phase.
-
Go find where you start Dials and add a call to enable snaps:
Objective-C:
[[DLSDials shared] start] [[DLSViewsPlugin activePlugin] enableSnaps]
Swift:
DLSDials.shared()?.start() DLSViewsPlugin.activePlugin()?.enableSnaps()
The Snaps project adds a new scheme "Dials.app + Snaps" which will build Dials with the Snaps plugin. Just start your iOS app then switch to that scheme and run Dials. Snaps support will be included automatically.
- Choose the "Views" tab in Dials.
- Click on the view whose constraints you want to edit.
- Find a constraint and click the edit button.
- Change the constraint.
- Hit save.