Skip to content

Commit

Permalink
Adds Swift 2.0 support
Browse files Browse the repository at this point in the history
ran the swift migration utility.
added `_` where necessary to prevent an API change (though maybe an API change
should be considered in order to be consistent with the rest of Swift?)
  • Loading branch information
derrh committed Jun 11, 2015
1 parent d70cbe5 commit b739e44
Show file tree
Hide file tree
Showing 20 changed files with 193 additions and 178 deletions.
4 changes: 2 additions & 2 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Nimble" ~> 1.0
github "Quick/Quick" ~> 0.3.1
github "Quick/Nimble" "swift-2.0"
github "Quick/Quick" "swift-2.0"
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Nimble" "v1.0.0-rc.1"
github "Quick/Quick" "v0.3.1"
github "Quick/Nimble" "fa73feeb156d8af7f47ae94dde07f1f7847bb1a3"
github "Quick/Quick" "d69e14d987b8e6bfc6963a7383ec176401ba67ed"
11 changes: 10 additions & 1 deletion Cartography.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@
54C96A08195063CD000CDD27 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0620;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Robert Böhnke";
TargetAttributes = {
54C96A10195063CD000CDD27 = {
Expand Down Expand Up @@ -720,6 +721,7 @@
INFOPLIST_FILE = Cartography/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Cartography;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -743,6 +745,7 @@
INFOPLIST_FILE = Cartography/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Cartography;
SKIP_INSTALL = YES;
};
Expand All @@ -764,6 +767,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = YES;
OTHER_SWIFT_FLAGS = "-DTEST";
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -780,6 +784,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = NO;
OTHER_SWIFT_FLAGS = "-DTEST";
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down Expand Up @@ -807,6 +812,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
METAL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Cartography;
SDKROOT = macosx;
SKIP_INSTALL = YES;
Expand All @@ -833,6 +839,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
METAL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Cartography;
SDKROOT = macosx;
SKIP_INSTALL = YES;
Expand All @@ -857,6 +864,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
METAL_ENABLE_DEBUG_INFO = YES;
OTHER_SWIFT_FLAGS = "-DTEST";
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand All @@ -877,6 +885,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
METAL_ENABLE_DEBUG_INFO = NO;
OTHER_SWIFT_FLAGS = "-DTEST";
PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -39,6 +39,8 @@
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -48,6 +50,7 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -39,6 +39,8 @@
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -48,6 +50,7 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
56 changes: 28 additions & 28 deletions Cartography/Align.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import AppKit
#endif

private func makeEqual<P: RelativeEquality>(attribute: LayoutProxy -> P, first: LayoutProxy, rest: [LayoutProxy]) -> [NSLayoutConstraint] {
return reduce(rest, []) { acc, current in
return rest.reduce([]) { acc, current in
current.view.car_translatesAutoresizingMaskIntoConstraints = false

return acc + [ attribute(first) == attribute(current) ]
Expand All @@ -25,96 +25,96 @@ private func makeEqual<P: RelativeEquality>(attribute: LayoutProxy -> P, first:
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(top first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.top }, first, rest)
public func align(top first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.top }, first: first, rest: rest)
}

/// Aligns multiple views by their right edge.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(right first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.right }, first, rest)
public func align(right first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.right }, first: first, rest: rest)
}

/// Aligns multiple views by their bottom edge.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(bottom first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.bottom }, first, rest)
public func align(bottom first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.bottom }, first: first, rest: rest)
}

/// Aligns multiple views by their left edge.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(left first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.left }, first, rest)
public func align(left first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.left }, first: first, rest: rest)
}

/// Aligns multiple views by their leading edge.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(leading first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.leading }, first, rest)
public func align(leading first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.leading }, first: first, rest: rest)
}

/// Aligns multiple vies by their trailing edge.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(trailing first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.trailing }, first, rest)
public func align(trailing first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.trailing }, first: first, rest: rest)
}

/// Aligns multiple views by their horizontal center.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(centerX first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.centerX }, first, rest)
public func align(centerX first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.centerX }, first: first, rest: rest)
}

/// Aligns multiple views by their vertical center.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(centerY first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.centerY }, first, rest)
public func align(centerY first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.centerY }, first: first, rest: rest)
}

/// Aligns multiple views by their baseline.
///
/// All views passed to this function will have
/// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`.
///
/// :returns: An array of `NSLayoutConstraint` instances.
/// - returns: An array of `NSLayoutConstraint` instances.
///
public func align(baseline first: LayoutProxy, rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.baseline }, first, rest)
public func align(baseline first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] {
return makeEqual({ $0.baseline }, first: first, rest: rest)
}
34 changes: 17 additions & 17 deletions Cartography/Compound.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ public protocol RelativeCompoundEquality : Compound { }

/// Declares a property equal to a the result of an expression.
///
/// :param: lhs The affected property. The associated view will have
/// - parameter lhs: The affected property. The associated view will have
/// `translatesAutoresizingMaskIntoConstraints` set to `false`.
/// :param: rhs The expression.
/// - parameter rhs: The expression.
///
/// :returns: An `NSLayoutConstraint`.
/// - returns: An `NSLayoutConstraint`.
///
public func == <P: RelativeCompoundEquality>(lhs: P, rhs: Expression<P>) -> [NSLayoutConstraint] {
return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value)
}

/// Declares a property equal to another compound property.
///
/// :param: lhs The affected property. The associated view will have
/// - parameter lhs: The affected property. The associated view will have
/// `translatesAutoresizingMaskIntoConstraints` set to `false`.
/// :param: rhs The other property.
/// - parameter rhs: The other property.
///
public func == <P: RelativeCompoundEquality>(lhs: P, rhs: P) -> [NSLayoutConstraint] {
return lhs.context.addConstraint(lhs, to: rhs)
Expand All @@ -49,47 +49,47 @@ public protocol RelativeCompoundInequality : Compound { }

/// Declares a property less than or equal to another compound property.
///
/// :param: lhs The affected property. The associated view will have
/// - parameter lhs: The affected property. The associated view will have
/// `translatesAutoresizingMaskIntoConstraints` set to `false`.
/// :param: rhs The other property.
/// - parameter rhs: The other property.
///
/// :returns: An `NSLayoutConstraint`.
/// - returns: An `NSLayoutConstraint`.
///
public func <= <P: RelativeCompoundInequality>(lhs: P, rhs: P) -> [NSLayoutConstraint] {
return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.LessThanOrEqual)
}

/// Declares a property greater than or equal to another compound property.
///
/// :param: lhs The affected property. The associated view will have
/// - parameter lhs: The affected property. The associated view will have
/// `translatesAutoresizingMaskIntoConstraints` set to `false`.
/// :param: rhs The other property.
/// - parameter rhs: The other property.
///
/// :returns: An `NSLayoutConstraint`.
/// - returns: An `NSLayoutConstraint`.
///
public func >= <P: RelativeCompoundInequality>(lhs: P, rhs: P) -> [NSLayoutConstraint] {
return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.GreaterThanOrEqual)
}

/// Declares a property less than or equal to the result of an expression.
///
/// :param: lhs The affected property. The associated view will have
/// - parameter lhs: The affected property. The associated view will have
/// `translatesAutoresizingMaskIntoConstraints` set to `false`.
/// :param: rhs The other property.
/// - parameter rhs: The other property.
///
/// :returns: An `NSLayoutConstraint`.
/// - returns: An `NSLayoutConstraint`.
///
public func <= <P: RelativeCompoundInequality>(lhs: P, rhs: Expression<P>) -> [NSLayoutConstraint] {
return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.LessThanOrEqual)
}

/// Declares a property greater than or equal to the result of an expression.
///
/// :param: lhs The affected property. The associated view will have
/// - parameter lhs: The affected property. The associated view will have
/// `translatesAutoresizingMaskIntoConstraints` set to `false`.
/// :param: rhs The other property.
/// - parameter rhs: The other property.
///
/// :returns: An `NSLayoutConstraint`.
/// - returns: An `NSLayoutConstraint`.
///
public func >= <P: RelativeCompoundInequality>(lhs: P, rhs: Expression<P>) -> [NSLayoutConstraint] {
return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.GreaterThanOrEqual)
Expand Down
4 changes: 2 additions & 2 deletions Cartography/ConstraintGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import Foundation
public class ConstraintGroup {
private var constraints: [Constraint] = []

@availability(OSX, introduced=10.10)
@availability(iOS, introduced=8.0)
@available(OSX, introduced=10.10)
@available(iOS, introduced=8.0)
public var active: Bool {
get {
return constraints.map({ $0.layoutConstraint.active }).reduce(true) { $0 && $1 }
Expand Down
2 changes: 1 addition & 1 deletion Cartography/Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Context {
constant: CGFloat(coefficients.constant))

if let to = to {
if let common = closestCommonAncestor(from.view, to.view ) {
if let common = closestCommonAncestor(from.view, b: to.view ) {
constraints.append(Constraint(view: common, layoutConstraint: layoutConstraint))
} else {
fatalError("No common superview found between \(from.view) and \(to.view)")
Expand Down
Loading

0 comments on commit b739e44

Please sign in to comment.