Skip to content

Commit

Permalink
Merge pull request #10 from fhisa/pr-update-for-swift-3
Browse files Browse the repository at this point in the history
SwiftyLayout 4 for Swift 3
  • Loading branch information
fhisa authored Sep 17, 2016
2 parents 8399609 + 2ab5be7 commit 81634c8
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 216 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGES

## 4.0.0

Update for Swift 3 and Xcode 8. This version isn't available for Swift 2.

## 3.0.2

Support Swift 2.3 & Xcode 8
Expand Down
6 changes: 5 additions & 1 deletion README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

SwiftyLayout は、Swiftプログラムにおいて、レイアウト制約(NSLayoutConstraint)を簡単な数式として定義できるようにするフレームワークです。

**[注意]** *[Swifty Methods](https://realm.io/news/swift-summit-swifty-methods-clarity-brevity/)([日本語訳](https://realm.io/jp/news/swift-summit-swifty-methods-clarity-brevity/))の影響を受けて、フレームワーク名を SwiftyLayout に変更しました。(旧名は FormulaStyleConstraint)*
## バージョンについて

- SwiftyLayout 3 は Swift 2 用です。
- SwiftyLayout 4 は Swift 3 用です。


## コード例

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

SwiftyLayout is a framework that allows to describe layout constraints (ie NSLayoutConstraint) as a simple mathematical formula in a Swift program.

**[NOTICE]** *The framework was renamed to SwiftyLayout (Formerly FormulaStyleConstraint) influenced by [Swifty Methods](https://realm.io/news/swift-summit-swifty-methods-clarity-brevity/).*
## About Version

- SwiftyLayout 3 for Swift 2
- SwiftyLayout 4 for Swift 3

## Code Examples

Expand Down
28 changes: 14 additions & 14 deletions SwiftyLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 305;
CURRENT_PROJECT_VERSION = 400;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -437,7 +437,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 305;
CURRENT_PROJECT_VERSION = 400;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -468,7 +468,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 305;
DYLIB_CURRENT_VERSION = 400;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = SwiftyLayout/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -477,7 +477,7 @@
PRODUCT_NAME = SwiftyLayout;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -488,15 +488,15 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 305;
DYLIB_CURRENT_VERSION = 400;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = SwiftyLayout/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.fobj.SwiftyLayout;
PRODUCT_NAME = SwiftyLayout;
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -509,7 +509,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.fobj.SwiftyLayoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -521,7 +521,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.fobj.SwiftyLayoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -532,7 +532,7 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 305;
DYLIB_CURRENT_VERSION = 400;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = SwiftyLayout/Info.plist;
Expand All @@ -544,7 +544,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -555,7 +555,7 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 305;
DYLIB_CURRENT_VERSION = 400;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = SwiftyLayout/Info.plist;
Expand All @@ -566,7 +566,7 @@
PRODUCT_NAME = SwiftyLayout;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -580,7 +580,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.fobj.SwiftyLayoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -594,7 +594,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.fobj.SwiftyLayoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion SwiftyLayout/ConstraintTerm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct ConstraintTerm

public init(
view v: AnyObject? = nil,
attribute a: NSLayoutAttribute = .NotAnAttribute,
attribute a: NSLayoutAttribute = .notAnAttribute,
multiplier m: CGFloat = 1.0,
constant c: CGFloat = 0.0)
{
Expand Down
2 changes: 1 addition & 1 deletion SwiftyLayout/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.3</string>
<string>4.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
23 changes: 12 additions & 11 deletions SwiftyLayout/Operators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

#endif


infix operator ~ {
precedence 100
associativity none
precedencegroup LayoutPriorityPrecedence {
associativity: right
higherThan: AssignmentPrecedence
}
infix operator ~ : LayoutPriorityPrecedence


public func ~ (lhs: NSLayoutConstraint, rhs: LayoutPriority) -> NSLayoutConstraint {
lhs.priority = rhs
Expand Down Expand Up @@ -127,12 +128,12 @@ public func / (lhs: ConstraintTerm, rhs: Double) -> ConstraintTerm {

// MARK: - x == y
public func == (lhs: ConstraintTerm, rhs: ConstraintTerm) -> NSLayoutConstraint {
return createLayoutConstraint(lhs, relatedBy: .Equal, rhs: rhs)
return createLayoutConstraint(lhs: lhs, relatedBy: .equal, rhs: rhs)
}

// MARK: - x == c
public func == (lhs: ConstraintTerm, rhs: CGFloat) -> NSLayoutConstraint {
return createLayoutConstraint(lhs, relatedBy: .Equal, rhs: rhs)
return createLayoutConstraint(lhs: lhs, relatedBy: .equal, rhs: rhs)
}

public func == (lhs: ConstraintTerm, rhs: Int) -> NSLayoutConstraint {
Expand All @@ -158,12 +159,12 @@ public func == (lhs: Double, rhs: ConstraintTerm) -> NSLayoutConstraint {

// MARK: - x <= y
public func <= (lhs: ConstraintTerm, rhs: ConstraintTerm) -> NSLayoutConstraint {
return createLayoutConstraint(lhs, relatedBy: .LessThanOrEqual, rhs: rhs)
return createLayoutConstraint(lhs: lhs, relatedBy: .lessThanOrEqual, rhs: rhs)
}

// MARK: - x <= c
public func <= (lhs: ConstraintTerm, rhs: CGFloat) -> NSLayoutConstraint {
return createLayoutConstraint(lhs, relatedBy: .LessThanOrEqual, rhs: rhs)
return createLayoutConstraint(lhs: lhs, relatedBy: .lessThanOrEqual, rhs: rhs)
}

public func <= (lhs: ConstraintTerm, rhs: Int) -> NSLayoutConstraint {
Expand All @@ -189,12 +190,12 @@ public func <= (lhs: Double, rhs: ConstraintTerm) -> NSLayoutConstraint {

// MARK: - x >= y
public func >= (lhs: ConstraintTerm, rhs: ConstraintTerm) -> NSLayoutConstraint {
return createLayoutConstraint(lhs, relatedBy: .GreaterThanOrEqual, rhs: rhs)
return createLayoutConstraint(lhs: lhs, relatedBy: .greaterThanOrEqual, rhs: rhs)
}

// MARK: - x >= c
public func >= (lhs: ConstraintTerm, rhs: CGFloat) -> NSLayoutConstraint {
return createLayoutConstraint(lhs, relatedBy: .GreaterThanOrEqual, rhs: rhs)
return createLayoutConstraint(lhs: lhs, relatedBy: .greaterThanOrEqual, rhs: rhs)
}

public func >= (lhs: ConstraintTerm, rhs: Int) -> NSLayoutConstraint {
Expand Down Expand Up @@ -236,7 +237,7 @@ private func createLayoutConstraint(lhs: ConstraintTerm, relatedBy: NSLayoutRela
let constraint = NSLayoutConstraint(
item: lhs.view!, attribute: lhs.attribute,
relatedBy: relatedBy,
toItem: nil, attribute: .NotAnAttribute,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1.0, constant: constant)
return constraint
}
2 changes: 1 addition & 1 deletion SwiftyLayout/UILayoutSupport+SwiftyLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public extension UILayoutSupport {
}

public subscript(attribute: NSLayoutAttribute) -> ConstraintTerm {
return layout(attribute)
return layout(attribute: attribute)
}
}
#endif
4 changes: 2 additions & 2 deletions SwiftyLayout/View+SwiftyLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

public subscript(attribute: NSLayoutAttribute) -> ConstraintTerm {
return layout(attribute)
return layout(attribute: attribute)
}
}

Expand All @@ -28,7 +28,7 @@
}

public subscript(attribute: NSLayoutAttribute) -> ConstraintTerm {
return layout(attribute)
return layout(attribute: attribute)
}
}
#endif
2 changes: 1 addition & 1 deletion SwiftyLayoutTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.3</string>
<string>4.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Loading

0 comments on commit 81634c8

Please sign in to comment.