Skip to content

Commit

Permalink
Snap is now SnapKit
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjpayne committed Apr 15, 2015
1 parent 529e758 commit 51662d5
Show file tree
Hide file tree
Showing 29 changed files with 176 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ before_install:
- gem install xcpretty -N
script:
- set -o pipefail
- xcodebuild -project Snap.xcodeproj -scheme "Snap iOS" -sdk iphonesimulator
- xcodebuild -project SnapKit.xcodeproj -scheme "SnapKit iOS" -sdk iphonesimulator
-destination "platform=iOS Simulator,name=iPhone 6" ONLY_ACTIVE_ARCH=NO test | xcpretty -c
- pod lib lint --quick
Binary file removed Assets/snap-banner.png
Binary file not shown.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
CHANGELOG
=======

# 0.10.0 - Next Release In Development
# 0.10.0 - April 15 2015

* **ANNOUNCEMENT**: Snap is now SnapKit
* **BREAKING:** The constraint making chain now utilises protocols to tighten the API's to avoid user error. This may break some syntaxes.
* **BREAKING:** Semantic `and` and `with` chain variables were removed
* Added `update###` functions to `Constraint` so their constants and priorities can be updated
* Added a `Snap.Config.interfaceLayoutDirection` variable for richer Leading/Trailing support.
* Added a `SnapKit.Config.interfaceLayoutDirection` variable for richer Leading/Trailing support.
* Fixed memory leaks that could occur on long lived views
* Ensure Swift 1.2 compatibility

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetTitle</key>
<string>Snap Constraint Make</string>
<string>SnapKit Constraint Make</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetTitle</key>
<string>Snap Constraint Remake</string>
<string>SnapKit Constraint Remake</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

<img src="https://raw.githubusercontent.com/Masonry/Snap/develop/Assets/snap-banner.png" alt="">
SnapKit

====

[![Build Status](https://travis-ci.org/Masonry/Snap.svg)](https://travis-ci.org/Masonry/Snap)
[![Build Status](https://travis-ci.org/SnapKit/SnapKit.svg)](https://travis-ci.org/SnapKit/SnapKit)

Snap is a light-weight layout framework which wraps AutoLayout with a nicer syntax. Snap has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable. Snap supports both iOS and OS X.
SnapKit is a light-weight layout framework which wraps AutoLayout with a nicer syntax. SnapKit has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable. SnapKit supports both iOS and OS X.

> Snap uses some Swift-only features like function overloading, so it cannot be used from Objective-C. Because of this we’ve chosen to swap prefixes from Masonry’s `mas_` to `snp_` so you can use both Masonry and Snap in the same project.
> SnapKit uses some Swift-only features like function overloading, so it cannot be used from Objective-C. Because of this we’ve chosen to swap prefixes from Masonry’s `mas_` to `snp_` so you can use both Masonry and SnapKit in the same project.
## Requirements

Expand All @@ -28,14 +28,14 @@ CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install
$ gem install cocoapods
```

To integrate Snap into your Xcode project using CocoaPods, specify it in your `Podfile`:
To integrate SnapKit into your Xcode project using CocoaPods, specify it in your `Podfile`:

```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Snap', '~> 0.9.2'
pod 'SnapKit', '~> 0.10.0'
```

Then, run the following command:
Expand All @@ -55,30 +55,30 @@ $ brew update
$ brew install carthage
```

To integrate Snap into your Xcode project using Carthage, specify it in your `Cartfile`:
To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`:

```
github "Masonry/Snap" >= 0.9.2
github "SnapKit/SnapKit" >= 0.10.0
```

### Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate Snap into your project manually.
If you prefer not to use either of the aforementioned dependency managers, you can integrate SnapKit into your project manually.

### Embedded Framework

- Add Snap as a [submodule](http://git-scm.com/docs/git-submodule) by opening the Terminal, `cd`-ing into your top-level project directory, and entering the following command:
- Add SnapKit as a [submodule](http://git-scm.com/docs/git-submodule) by opening the Terminal, `cd`-ing into your top-level project directory, and entering the following command:

```bash
$ git submodule add https://github.com/Masonry/Snap.git
$ git submodule add https://github.com/SnapKit/SnapKit.git
```

- Open the `Snap` folder, and drag `Snap.xcodeproj` into the file navigator of your app project.
- Open the `SnapKit` folder, and drag `SnapKit.xcodeproj` into the file navigator of your app project.
- In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
- Ensure that the deployment target of Snap.framework matches that of the application target.
- Ensure that the deployment target of SnapKit.framework matches that of the application target.
- In the tab bar at the top of that window, open the "Build Phases" panel.
- Expand the "Target Dependencies" group, and add `Snap.framework`.
- Click on the `+` button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add `Snap.framework`.
- Expand the "Target Dependencies" group, and add `SnapKit.framework`.
- Click on the `+` button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add `SnapKit.framework`.

## What's wrong with NSLayoutConstraints?

Expand Down Expand Up @@ -160,9 +160,9 @@ view1.snp_makeConstraints { (make) -> Void in
```

Also note in the first example we had to add the constraints to the superview `superview.addConstraints`.
Snap however will automagically add constraints to the appropriate view.
SnapKit however will automagically add constraints to the appropriate view.

Snap will also call `view1.setTranslatesAutoresizingMaskIntoConstraints(false)` for you.
SnapKit will also call `view1.setTranslatesAutoresizingMaskIntoConstraints(false)` for you.

## Not all things are created equal

Expand Down Expand Up @@ -214,7 +214,7 @@ make.width.lessThanOrEqualTo(400)
```

However Auto Layout does not allow alignment attributes such as left, right, centerY etc to be set to constant values.
So if you pass a primitive for these attributes Snap will turn these into constraints relative to the view&rsquo;s superview ie:
So if you pass a primitive for these attributes SnapKit will turn these into constraints relative to the view&rsquo;s superview ie:
```swift
// creates view.left <= view.superview.left + 10
make.left.lessThanOrEqualTo(10)
Expand All @@ -241,14 +241,14 @@ make.left.equalTo(view).offset(UIEdgeInsetsMake(10, 0, 10, 0))
Priorities are can be tacked on to the end of a constraint chain like so:
```swift
make.left.greaterThanOrEqualTo(label.snp_left).with.priorityLow();
make.left.greaterThanOrEqualTo(label.snp_left).priorityLow();

make.top.equalTo(label.snp_top).with.priority(600);
make.top.equalTo(label.snp_top).priority(600);
```

## Composition, composition, composition

Snap also gives you a few convenience methods which create multiple constraints at the same time.
SnapKit also gives you a few convenience methods which create multiple constraints at the same time.

#### edges

Expand Down Expand Up @@ -285,14 +285,14 @@ You can chain view attributes for increased readability:

```swift
// All edges but the top should equal those of the superview
make.left.right.and.bottom.equalTo(superview)
make.left.right.bottom.equalTo(superview)
make.top.equalTo(otherView)
```

## Hold on for dear life

Sometimes you need modify existing constraints in order to animate or remove/replace constraints.
In Snap there are a few different approaches to updating constraints.
In SnapKit there are a few different approaches to updating constraints.

#### 1. References
You can hold on to a reference of a particular constraint by assigning the result of a constraint make expression to a local variable or a class property.
Expand All @@ -306,8 +306,8 @@ var topConstraint: Constraint? = nil

// when making constraints
view1.snp_makeConstraints { make in
self.topConstraint = make.top.equalTo(superview).with.offset(padding.top).constraint
make.left.equalTo(superview).with.offset(padding.left)
self.topConstraint = make.top.equalTo(superview).offset(padding.top).constraint
make.left.equalTo(superview).offset(padding.left)
}

...
Expand All @@ -317,7 +317,7 @@ self.topConstraint.uninstall()

### 2. snp_remakeConstraints

`snp_remakeConstraints` is similar to `snp_makeConstraints`, but will first remove all existing constraints installed by Snap.
`snp_remakeConstraints` is similar to `snp_makeConstraints`, but will first remove all existing constraints installed by SnapKit.

```swift
func changeButtonPosition() {
Expand Down
41 changes: 0 additions & 41 deletions Snap.xcworkspace/xcshareddata/Snappy.xccheckout

This file was deleted.

8 changes: 4 additions & 4 deletions Snap.podspec → SnapKit.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = 'Snap'
s.version = '0.9.2'
s.name = 'SnapKit'
s.version = '0.10.0'
s.license = 'MIT'
s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.'
s.homepage = 'https://github.com/Masonry/Snap'
s.homepage = 'https://github.com/SnapKit/SnapKit'
s.authors = { 'Robert Payne' => '[email protected]' }
s.social_media_url = 'http://twitter.com/robertjpayne'
s.source = { :git => 'https://github.com/Masonry/Snap.git', :tag => '0.9.2' }
s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '0.10.0' }

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.9'
Expand Down
Loading

0 comments on commit 51662d5

Please sign in to comment.