From 1ef097b2a92834ecf1a39fe4114a2b1e20e88098 Mon Sep 17 00:00:00 2001 From: Luko Gjenero Date: Tue, 8 Oct 2019 20:02:10 +0200 Subject: [PATCH 1/2] Because constrain function is defined in CommonUISDK looks like XCode11 cannot complie Cartography pod anymore. Renaming constrain functions to cg_constrain seems to fix the problem --- Cartography/Constrain.swift | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cartography/Constrain.swift b/Cartography/Constrain.swift index a1718d8..ae8202b 100644 --- a/Cartography/Constrain.swift +++ b/Cartography/Constrain.swift @@ -12,7 +12,7 @@ import Foundation /// /// - parameter clear: The `ConstraintGroup` whose constraints should be removed. /// -public func constrain(clear group: ConstraintGroup) { +public func cg_constrain(clear group: ConstraintGroup) { group.replaceConstraints([]) } @@ -23,7 +23,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item: A, replace group: ConstraintGroup = .init(), block: (A.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item: A, replace group: ConstraintGroup = .init(), block: (A.ProxyType) -> Void) -> ConstraintGroup { let proxy = item.asProxy() block(proxy) @@ -41,7 +41,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -63,7 +63,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -87,7 +87,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -113,7 +113,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -141,7 +141,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -171,7 +171,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -203,7 +203,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, _ item8: H, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType, H.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, _ item8: H, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType, H.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -237,7 +237,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, _ item8: H, _ item9: I, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType, H.ProxyType, I.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, _ item8: H, _ item9: I, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType, H.ProxyType, I.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -273,7 +273,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `item`. /// -@discardableResult public func constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, _ item8: H, _ item9: I, _ item10: J, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType, H.ProxyType, I.ProxyType, J.ProxyType) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ item1: A, _ item2: B, _ item3: C, _ item4: D, _ item5: E, _ item6: F, _ item7: G, _ item8: H, _ item9: I, _ item10: J, replace group: ConstraintGroup = .init(), block: (A.ProxyType, B.ProxyType, C.ProxyType, D.ProxyType, E.ProxyType, F.ProxyType, G.ProxyType, H.ProxyType, I.ProxyType, J.ProxyType) -> Void) -> ConstraintGroup { let ctx = Context() let proxy1 = item1.asProxy(context: ctx) @@ -301,7 +301,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `items`. /// -@discardableResult public func constrain(_ items: [T], replace group: ConstraintGroup = .init(), block: ([T.ProxyType]) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ items: [T], replace group: ConstraintGroup = .init(), block: ([T.ProxyType]) -> Void) -> ConstraintGroup { let ctx = Context() let proxy = items.map { $0.asProxy(context: ctx) } @@ -319,7 +319,7 @@ public func constrain(clear group: ConstraintGroup) { /// replaced. /// - parameter block: A block that declares the layout for `items`. /// -@discardableResult public func constrain(_ items: [T: U], replace group: ConstraintGroup = .init(), block: ([T: U.ProxyType]) -> Void) -> ConstraintGroup { +@discardableResult public func cg_constrain(_ items: [T: U], replace group: ConstraintGroup = .init(), block: ([T: U.ProxyType]) -> Void) -> ConstraintGroup { let ctx = Context() let proxy: [T: U.ProxyType] = items.mapValues { $0.asProxy(context: ctx) } From 1c23eaef3041db75760446a55b155fabf413b090 Mon Sep 17 00:00:00 2001 From: Luko Gjenero Date: Tue, 8 Oct 2019 20:15:11 +0200 Subject: [PATCH 2/2] Updated the tests as well --- CartographyTests/AlignSpec.swift | 8 +-- CartographyTests/ConstraintGroupSpec.swift | 10 ++-- CartographyTests/DimensionSpec.swift | 32 +++++------ CartographyTests/DistributeSpec.swift | 12 ++-- CartographyTests/EdgeSpec.swift | 66 +++++++++++----------- CartographyTests/EdgesSpec.swift | 16 +++--- CartographyTests/LayoutGuideSpec.swift | 14 ++--- CartographyTests/LayoutSupportSpec.swift | 18 +++--- CartographyTests/MemoryLeakSpec.swift | 2 +- CartographyTests/PointSpec.swift | 10 ++-- CartographyTests/PrioritySpec.swift | 4 +- CartographyTests/SizeSpec.swift | 8 +-- CartographyTests/ViewHierarchySpec.swift | 14 ++--- CartographyTests/ViewLayoutGuideSpec.swift | 12 ++-- CartographyTests/ViewProxyTests.swift | 2 +- 15 files changed, 114 insertions(+), 114 deletions(-) diff --git a/CartographyTests/AlignSpec.swift b/CartographyTests/AlignSpec.swift index 8625924..84b038e 100644 --- a/CartographyTests/AlignSpec.swift +++ b/CartographyTests/AlignSpec.swift @@ -22,7 +22,7 @@ class AlignSpec: QuickSpec { viewC = TestView(frame: CGRect.zero) window.addSubview(viewC) - constrain(viewA) { view in + cg_constrain(viewA) { view in view.height == 200 view.width == 200 @@ -33,7 +33,7 @@ class AlignSpec: QuickSpec { describe("for edges") { beforeEach { - constrain(viewA, viewB, viewC) { viewA, viewB, viewC in + cg_constrain(viewA, viewB, viewC) { viewA, viewB, viewC in align(top: viewA, viewB, viewC) align(right: viewA, viewB, viewC) align(bottom: viewA, viewB, viewC) @@ -55,7 +55,7 @@ class AlignSpec: QuickSpec { describe("for horizontal and vertical centers") { beforeEach { - constrain(viewA, viewB, viewC) { viewA, viewB, viewC in + cg_constrain(viewA, viewB, viewC) { viewA, viewB, viewC in viewA.size == viewB.size viewB.size == viewC.size @@ -78,7 +78,7 @@ class AlignSpec: QuickSpec { describe("no constraints") { it("should have no constraints for a single view alignment") { - constrain(viewA) { viewA in + cg_constrain(viewA) { viewA in let constraints = align(top: [viewA]) expect(constraints.count).to(equal(0)) diff --git a/CartographyTests/ConstraintGroupSpec.swift b/CartographyTests/ConstraintGroupSpec.swift index eb467e3..7d926f9 100644 --- a/CartographyTests/ConstraintGroupSpec.swift +++ b/CartographyTests/ConstraintGroupSpec.swift @@ -20,14 +20,14 @@ class ConstraintGroupSpec: QuickSpec { var b: ConstraintGroup! beforeEach { - a = constrain(view1) { view in + a = cg_constrain(view1) { view in view.width == 100 view.height == 100 } a.active = false - b = constrain(view1) { view in + b = cg_constrain(view1) { view in view.width == 200 view.height == 200 } @@ -60,7 +60,7 @@ class ConstraintGroupSpec: QuickSpec { view2 = TestView(frame: CGRect.zero) window.addSubview(view2) - constrain(view1, view2) { view1, view2 in + cg_constrain(view1, view2) { view1, view2 in view1.top == view1.superview!.top + 10 view1.left == view1.superview!.left + 10 view1.right == view1.superview!.right - 10 @@ -75,7 +75,7 @@ class ConstraintGroupSpec: QuickSpec { } it("should update the view") { - let group = constrain(view2) { view2 in + let group = cg_constrain(view2) { view2 in view2.height == 100 } @@ -83,7 +83,7 @@ class ConstraintGroupSpec: QuickSpec { expect(view2.frame.height).to(equal(100)) - constrain(view2, replace: group) { view2 in + cg_constrain(view2, replace: group) { view2 in view2.bottom >= view2.superview!.bottom } diff --git a/CartographyTests/DimensionSpec.swift b/CartographyTests/DimensionSpec.swift index 1dfe95c..33bf789 100644 --- a/CartographyTests/DimensionSpec.swift +++ b/CartographyTests/DimensionSpec.swift @@ -17,7 +17,7 @@ class DimensionSpec: QuickSpec { describe("LayoutProxy.width") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.width == view.superview!.width } @@ -27,7 +27,7 @@ class DimensionSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.width <= view.superview!.width view.width >= view.superview!.width } @@ -38,7 +38,7 @@ class DimensionSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.width == view.superview!.width + 100 } @@ -48,7 +48,7 @@ class DimensionSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.width == view.superview!.width - 100 } @@ -58,7 +58,7 @@ class DimensionSpec: QuickSpec { } it("should support multiplication") { - constrain(view) { view in + cg_constrain(view) { view in view.width == view.superview!.width * 2 } @@ -68,7 +68,7 @@ class DimensionSpec: QuickSpec { } it("should support division") { - constrain(view) { view in + cg_constrain(view) { view in view.width == view.superview!.width / 2 } @@ -78,7 +78,7 @@ class DimensionSpec: QuickSpec { } it("should support complex expressions") { - constrain(view) { view in + cg_constrain(view) { view in view.width == view.superview!.width / 2 + 100 } @@ -88,7 +88,7 @@ class DimensionSpec: QuickSpec { } it("should support numerical equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.width == 200 } @@ -100,7 +100,7 @@ class DimensionSpec: QuickSpec { describe("LayoutProxy.height") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.height == view.superview!.height } @@ -110,7 +110,7 @@ class DimensionSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.height <= view.superview!.height view.height >= view.superview!.height } @@ -121,7 +121,7 @@ class DimensionSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.height == view.superview!.height + 100 } @@ -131,7 +131,7 @@ class DimensionSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.height == view.superview!.height - 100 } @@ -141,7 +141,7 @@ class DimensionSpec: QuickSpec { } it("should support multiplication") { - constrain(view) { view in + cg_constrain(view) { view in view.height == view.superview!.height * 2 } @@ -151,7 +151,7 @@ class DimensionSpec: QuickSpec { } it("should support division") { - constrain(view) { view in + cg_constrain(view) { view in view.height == view.superview!.height / 2 } @@ -161,7 +161,7 @@ class DimensionSpec: QuickSpec { } it("should support complex expressions") { - constrain(view) { view in + cg_constrain(view) { view in view.height == view.superview!.height / 2 + 100 } @@ -171,7 +171,7 @@ class DimensionSpec: QuickSpec { } it("should support numerical equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.height == 200 } diff --git a/CartographyTests/DistributeSpec.swift b/CartographyTests/DistributeSpec.swift index 47ca09a..a10e319 100644 --- a/CartographyTests/DistributeSpec.swift +++ b/CartographyTests/DistributeSpec.swift @@ -24,7 +24,7 @@ class DistributeSpec: QuickSpec { viewC = TestView(frame: CGRect.zero) window.addSubview(viewC) - constrain(viewA, viewB, viewC, replace: constraintsGroup) { viewA, viewB, viewC in + cg_constrain(viewA, viewB, viewC, replace: constraintsGroup) { viewA, viewB, viewC in viewA.width == 100 viewA.height == 100 @@ -38,7 +38,7 @@ class DistributeSpec: QuickSpec { describe("from left to right") { beforeEach { - constrain(viewA, viewB, viewC) { viewA, viewB, viewC in + cg_constrain(viewA, viewB, viewC) { viewA, viewB, viewC in align(centerY: viewA, viewB, viewC) distribute(by: 10, leftToRight: viewA, viewB, viewC) } @@ -61,7 +61,7 @@ class DistributeSpec: QuickSpec { describe("vertically") { beforeEach { - constrain(viewA, viewB, viewC) { viewA, viewB, viewC in + cg_constrain(viewA, viewB, viewC) { viewA, viewB, viewC in align(centerX: viewA, viewB, viewC) distribute(by: 10, vertically: viewA, viewB, viewC) } @@ -84,7 +84,7 @@ class DistributeSpec: QuickSpec { describe("no constraints") { it("should have no constraints for a single view distribution") { - constrain(viewA) { viewA in + cg_constrain(viewA) { viewA in let constraints = distribute(horizontally: [viewA]) expect(constraints.count).to(equal(0)) @@ -99,7 +99,7 @@ class DistributeSpec: QuickSpec { describe("When distributing width") { beforeEach { - constrain(viewA, viewB, viewC, replace: constraintsGroup) { + cg_constrain(viewA, viewB, viewC, replace: constraintsGroup) { viewA, viewB, viewC in viewA.width == 50 @@ -119,7 +119,7 @@ class DistributeSpec: QuickSpec { describe("When distributing height") { beforeEach { - constrain(viewA, viewB, viewC, replace: constraintsGroup) { + cg_constrain(viewA, viewB, viewC, replace: constraintsGroup) { viewA, viewB, viewC in viewA.height == 50 diff --git a/CartographyTests/EdgeSpec.swift b/CartographyTests/EdgeSpec.swift index b752a86..05d623a 100644 --- a/CartographyTests/EdgeSpec.swift +++ b/CartographyTests/EdgeSpec.swift @@ -14,7 +14,7 @@ class EdgeSpec: QuickSpec { view = TestView(frame: CGRect.zero) window.addSubview(view) - constrain(view) { view in + cg_constrain(view) { view in view.height == 200 view.width == 200 } @@ -22,7 +22,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.top") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.top == view.superview!.top } @@ -32,7 +32,7 @@ class EdgeSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.top <= view.superview!.top view.top >= view.superview!.top } @@ -43,7 +43,7 @@ class EdgeSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.top == view.superview!.top + 100 } @@ -53,7 +53,7 @@ class EdgeSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.top == view.superview!.top - 100 } @@ -65,7 +65,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.right") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.right == view.superview!.right } @@ -75,7 +75,7 @@ class EdgeSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.right <= view.superview!.right view.right >= view.superview!.right } @@ -86,7 +86,7 @@ class EdgeSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.right == view.superview!.right + 100 } @@ -96,7 +96,7 @@ class EdgeSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.right == view.superview!.right - 100 } @@ -108,7 +108,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.bottom") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.bottom == view.superview!.bottom } @@ -118,7 +118,7 @@ class EdgeSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.bottom <= view.superview!.bottom view.bottom >= view.superview!.bottom } @@ -129,7 +129,7 @@ class EdgeSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.bottom == view.superview!.bottom + 100 } @@ -139,7 +139,7 @@ class EdgeSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.bottom == view.superview!.bottom - 100 } @@ -151,7 +151,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.left") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.left == view.superview!.left } @@ -161,7 +161,7 @@ class EdgeSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.left <= view.superview!.left view.left >= view.superview!.left } @@ -172,7 +172,7 @@ class EdgeSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.left == view.superview!.left + 100 } @@ -182,7 +182,7 @@ class EdgeSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.left == view.superview!.left - 100 } @@ -194,7 +194,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.centerX") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.centerX == view.superview!.centerX } @@ -204,7 +204,7 @@ class EdgeSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.centerX <= view.superview!.centerX view.centerX >= view.superview!.centerX } @@ -215,7 +215,7 @@ class EdgeSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.centerX == view.superview!.centerX + 100 } @@ -225,7 +225,7 @@ class EdgeSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.centerX == view.superview!.centerX - 100 } @@ -235,7 +235,7 @@ class EdgeSpec: QuickSpec { } it("should support multiplication") { - constrain(view) { view in + cg_constrain(view) { view in view.centerX == view.superview!.centerX * 2 } @@ -245,7 +245,7 @@ class EdgeSpec: QuickSpec { } it("should support division") { - constrain(view) { view in + cg_constrain(view) { view in view.centerX == view.superview!.centerX / 2 } @@ -257,7 +257,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.centerY") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.centerY == view.superview!.centerY } @@ -267,7 +267,7 @@ class EdgeSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.centerY <= view.superview!.centerY view.centerY >= view.superview!.centerY } @@ -278,7 +278,7 @@ class EdgeSpec: QuickSpec { } it("should support addition") { - constrain(view) { view in + cg_constrain(view) { view in view.centerY == view.superview!.centerY + 100 } @@ -288,7 +288,7 @@ class EdgeSpec: QuickSpec { } it("should support subtraction") { - constrain(view) { view in + cg_constrain(view) { view in view.centerY == view.superview!.centerY - 100 } @@ -298,7 +298,7 @@ class EdgeSpec: QuickSpec { } it("should support multiplication") { - constrain(view) { view in + cg_constrain(view) { view in view.centerY == view.superview!.centerY * 2 } @@ -308,7 +308,7 @@ class EdgeSpec: QuickSpec { } it("should support division") { - constrain(view) { view in + cg_constrain(view) { view in view.centerY == view.superview!.centerY / 2 } @@ -326,7 +326,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.topMargin") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.top == view.superview!.topMargin } @@ -338,7 +338,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.rightMargin") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.right == view.superview!.rightMargin } @@ -350,7 +350,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.bottomMargin") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.bottom == view.superview!.bottomMargin } @@ -362,7 +362,7 @@ class EdgeSpec: QuickSpec { describe("LayoutProxy.leftMargin") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.left == view.superview!.leftMargin } diff --git a/CartographyTests/EdgesSpec.swift b/CartographyTests/EdgesSpec.swift index 015c6e1..4ae7049 100644 --- a/CartographyTests/EdgesSpec.swift +++ b/CartographyTests/EdgesSpec.swift @@ -17,7 +17,7 @@ class EdgesSpec: QuickSpec { describe("LayoutProxy.edges") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == view.superview!.edges } @@ -29,7 +29,7 @@ class EdgesSpec: QuickSpec { describe("LayoutProxy.edges") { it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.edges <= view.superview!.edges view.edges >= view.superview!.edges } @@ -42,7 +42,7 @@ class EdgesSpec: QuickSpec { describe("inset") { it("should inset all edges with the same amount") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == inset(view.superview!.edges, 20) } @@ -52,7 +52,7 @@ class EdgesSpec: QuickSpec { } it("should inset the horizontal and vertical edge individually") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == inset(view.superview!.edges, 20, 30) } @@ -62,7 +62,7 @@ class EdgesSpec: QuickSpec { } it("should inset the horizontal edges") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == inset(view.superview!.edges, horizontally: 20) } @@ -72,7 +72,7 @@ class EdgesSpec: QuickSpec { } it("should inset the vertical edges") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == inset(view.superview!.edges, vertically: 30) } @@ -82,7 +82,7 @@ class EdgesSpec: QuickSpec { } it("should inset all edges individually") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == inset(view.superview!.edges, 10, 20, 30, 40) } @@ -100,7 +100,7 @@ class EdgesSpec: QuickSpec { describe("LayoutProxy.edgesWithinMargins") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == view.superview!.edgesWithinMargins } diff --git a/CartographyTests/LayoutGuideSpec.swift b/CartographyTests/LayoutGuideSpec.swift index 020b093..eda38ac 100644 --- a/CartographyTests/LayoutGuideSpec.swift +++ b/CartographyTests/LayoutGuideSpec.swift @@ -30,7 +30,7 @@ final class LayoutGuideSpec: QuickSpec { describe("LayoutGuideProxy") { it("should support relative equalities") { - constrain(layoutGuide) { layoutGuide in + cg_constrain(layoutGuide) { layoutGuide in layoutGuide.edges == layoutGuide.owningView!.edges } @@ -53,7 +53,7 @@ final class LayoutGuideSpec: QuickSpec { } it("should support inequalities") { - constrain(layoutGuide) { layoutGuide in + cg_constrain(layoutGuide) { layoutGuide in layoutGuide.top >= layoutGuide.owningView!.top layoutGuide.bottom <= layoutGuide.owningView!.bottom @@ -85,7 +85,7 @@ final class LayoutGuideSpec: QuickSpec { } it("should support addition") { - constrain(layoutGuide) { layoutGuide in + cg_constrain(layoutGuide) { layoutGuide in layoutGuide.leading == layoutGuide.owningView!.leading + 10 } @@ -102,7 +102,7 @@ final class LayoutGuideSpec: QuickSpec { } it("should support subtraction") { - constrain(layoutGuide) { layoutGuide in + cg_constrain(layoutGuide) { layoutGuide in layoutGuide.trailing == layoutGuide.owningView!.trailing - 10 } @@ -119,7 +119,7 @@ final class LayoutGuideSpec: QuickSpec { } it("should support multiplication") { - constrain(layoutGuide) { layoutGuide in + cg_constrain(layoutGuide) { layoutGuide in layoutGuide.width == 0.5 * layoutGuide.owningView!.width } @@ -136,7 +136,7 @@ final class LayoutGuideSpec: QuickSpec { } it("should support division") { - constrain(layoutGuide) { layoutGuide in + cg_constrain(layoutGuide) { layoutGuide in layoutGuide.width == layoutGuide.owningView!.width / 2 } @@ -153,7 +153,7 @@ final class LayoutGuideSpec: QuickSpec { } it("should support centering") { - constrain(layoutGuide) { layoutGuide in + cg_constrain(layoutGuide) { layoutGuide in layoutGuide.center == layoutGuide.owningView!.center } diff --git a/CartographyTests/LayoutSupportSpec.swift b/CartographyTests/LayoutSupportSpec.swift index 2fc857a..62a686a 100644 --- a/CartographyTests/LayoutSupportSpec.swift +++ b/CartographyTests/LayoutSupportSpec.swift @@ -20,7 +20,7 @@ class LayoutSupportSpec: QuickSpec { viewController = UIViewController() viewController.view.addSubview(view) - constrain(view) { view in + cg_constrain(view) { view in view.height == 200 view.width == 200 } @@ -43,7 +43,7 @@ class LayoutSupportSpec: QuickSpec { viewController.view.layoutIfNeeded() - constrain(view, viewController.car_topLayoutGuide) { view, topLayoutGuide in + cg_constrain(view, viewController.car_topLayoutGuide) { view, topLayoutGuide in view.top == topLayoutGuide.bottom } viewController.view.layoutIfNeeded() @@ -52,7 +52,7 @@ class LayoutSupportSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view, viewController.car_topLayoutGuide) { view, topLayoutGuide in + cg_constrain(view, viewController.car_topLayoutGuide) { view, topLayoutGuide in view.top <= topLayoutGuide.bottom view.top >= topLayoutGuide.bottom } @@ -63,7 +63,7 @@ class LayoutSupportSpec: QuickSpec { } it("should support addition") { - constrain(view, viewController.car_topLayoutGuide) { view, topGuide in + cg_constrain(view, viewController.car_topLayoutGuide) { view, topGuide in view.top == topGuide.bottom + 100 } @@ -73,7 +73,7 @@ class LayoutSupportSpec: QuickSpec { } it("should support subtraction") { - constrain(view, viewController.car_topLayoutGuide) { view, topGuide in + cg_constrain(view, viewController.car_topLayoutGuide) { view, topGuide in view.top == topGuide.bottom - 100 } @@ -85,7 +85,7 @@ class LayoutSupportSpec: QuickSpec { describe("LayoutSupport.bottom") { it("should support relative equalities") { - constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in + cg_constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in view.bottom == bottomGuide.top } viewController.view.layoutIfNeeded() @@ -94,7 +94,7 @@ class LayoutSupportSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in + cg_constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in view.bottom <= bottomGuide.top view.bottom >= bottomGuide.top } @@ -105,7 +105,7 @@ class LayoutSupportSpec: QuickSpec { } it("should support addition") { - constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in + cg_constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in view.bottom == bottomGuide.top + 100 } @@ -115,7 +115,7 @@ class LayoutSupportSpec: QuickSpec { } it("should support subtraction") { - constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in + cg_constrain(view, viewController.car_bottomLayoutGuide) { view, bottomGuide in view.bottom == bottomGuide.top - 100 } diff --git a/CartographyTests/MemoryLeakSpec.swift b/CartographyTests/MemoryLeakSpec.swift index 2edaafe..4b2ff09 100644 --- a/CartographyTests/MemoryLeakSpec.swift +++ b/CartographyTests/MemoryLeakSpec.swift @@ -24,7 +24,7 @@ class MemoryLeakSpec: QuickSpec { weak_viewA = viewA weak_viewB = viewB - constrain(viewA, viewB) { viewA, viewB in + cg_constrain(viewA, viewB) { viewA, viewB in viewA.top == viewB.top viewB.bottom == viewA.bottom } diff --git a/CartographyTests/PointSpec.swift b/CartographyTests/PointSpec.swift index 9d497e6..b08d683 100644 --- a/CartographyTests/PointSpec.swift +++ b/CartographyTests/PointSpec.swift @@ -14,7 +14,7 @@ class PointSpec: QuickSpec { view = TestView(frame: CGRect.zero) window.addSubview(view) - constrain(view) { view in + cg_constrain(view) { view in view.width == 200 view.height == 200 } @@ -22,7 +22,7 @@ class PointSpec: QuickSpec { describe("LayoutProxy.center") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.center == view.superview!.center } @@ -32,7 +32,7 @@ class PointSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.center <= view.superview!.center view.center >= view.superview!.center } @@ -51,7 +51,7 @@ class PointSpec: QuickSpec { describe("LayoutProxy.centerWithinMargins") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.centerWithinMargins == view.superview!.center } @@ -61,7 +61,7 @@ class PointSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.centerWithinMargins <= view.superview!.center view.centerWithinMargins >= view.superview!.center } diff --git a/CartographyTests/PrioritySpec.swift b/CartographyTests/PrioritySpec.swift index ff0d4a2..9d996cc 100644 --- a/CartographyTests/PrioritySpec.swift +++ b/CartographyTests/PrioritySpec.swift @@ -18,7 +18,7 @@ class PrioritySpec: QuickSpec { it("should operate on a single constraint") { var constraint: NSLayoutConstraint! - constrain(view) { view in + cg_constrain(view) { view in constraint = view.width == 200 ~ LayoutPriority(100) } @@ -28,7 +28,7 @@ class PrioritySpec: QuickSpec { it("should operate on an array of constraints") { var constraints: [NSLayoutConstraint]! - constrain(view) { view in + cg_constrain(view) { view in constraints = (view.size <= view.superview!.size ~ LayoutPriority(100)) } diff --git a/CartographyTests/SizeSpec.swift b/CartographyTests/SizeSpec.swift index a71d7aa..dd5a15f 100644 --- a/CartographyTests/SizeSpec.swift +++ b/CartographyTests/SizeSpec.swift @@ -17,7 +17,7 @@ class SizeSpec: QuickSpec { describe("LayoutProxy.size") { it("should support relative equalities") { - constrain(view) { view in + cg_constrain(view) { view in view.size == view.superview!.size } @@ -27,7 +27,7 @@ class SizeSpec: QuickSpec { } it("should support relative inequalities") { - constrain(view) { view in + cg_constrain(view) { view in view.size <= view.superview!.size view.size >= view.superview!.size } @@ -38,7 +38,7 @@ class SizeSpec: QuickSpec { } it("should support multiplication") { - constrain(view) { view in + cg_constrain(view) { view in view.size == view.superview!.size * 2 } @@ -48,7 +48,7 @@ class SizeSpec: QuickSpec { } it("should support division") { - constrain(view) { view in + cg_constrain(view) { view in view.size == view.superview!.size / 2 } diff --git a/CartographyTests/ViewHierarchySpec.swift b/CartographyTests/ViewHierarchySpec.swift index adeba5d..fcf4181 100644 --- a/CartographyTests/ViewHierarchySpec.swift +++ b/CartographyTests/ViewHierarchySpec.swift @@ -11,7 +11,7 @@ class ViewHierarchySpec: QuickSpec { let viewB = TestView() expect({ - constrain(viewA, viewB) { viewA, viewB in + cg_constrain(viewA, viewB) { viewA, viewB in viewA.width == viewB.width } }()).to(raiseException()) @@ -20,7 +20,7 @@ class ViewHierarchySpec: QuickSpec { it("should consider a view its own closest common ancestor") { let view = TestView() - constrain(view) { view in + cg_constrain(view) { view in view.width == 200 } @@ -33,7 +33,7 @@ class ViewHierarchySpec: QuickSpec { parent.addSubview(child) - constrain(parent, child) { parent, child in + cg_constrain(parent, child) { parent, child in parent.width == child.width } @@ -48,7 +48,7 @@ class ViewHierarchySpec: QuickSpec { grandparent.addSubview(parent) parent.addSubview(child) - constrain(grandparent, child) { grandparent, child in + cg_constrain(grandparent, child) { grandparent, child in grandparent.width == child.width } @@ -63,7 +63,7 @@ class ViewHierarchySpec: QuickSpec { parent.addSubview(childA) parent.addSubview(childB) - constrain(childA, childB) { childA, childB in + cg_constrain(childA, childB) { childA, childB in childA.width == childB.width } @@ -82,7 +82,7 @@ class ViewHierarchySpec: QuickSpec { parentA.addSubview(childA) parentB.addSubview(childB) - constrain(childA, childB) { childA, childB in + cg_constrain(childA, childB) { childA, childB in childA.width == childB.width } @@ -99,7 +99,7 @@ class ViewHierarchySpec: QuickSpec { grandparent.addSubview(parentB) parentA.addSubview(childA) - constrain(childA, parentB) { childA, parentB in + cg_constrain(childA, parentB) { childA, parentB in childA.width == parentB.width } diff --git a/CartographyTests/ViewLayoutGuideSpec.swift b/CartographyTests/ViewLayoutGuideSpec.swift index 951b887..1c4a259 100644 --- a/CartographyTests/ViewLayoutGuideSpec.swift +++ b/CartographyTests/ViewLayoutGuideSpec.swift @@ -26,7 +26,7 @@ final class ViewLayoutGuideSpec: QuickSpec { } it("Views should align to edges within margins") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == view.superview!.layoutMarginsGuide.edges } @@ -39,7 +39,7 @@ final class ViewLayoutGuideSpec: QuickSpec { } it("Views should center within margins") { - constrain(view) { view in + cg_constrain(view) { view in view.center == view.superview!.layoutMarginsGuide.center view.width == 200 @@ -67,7 +67,7 @@ final class ViewLayoutGuideSpec: QuickSpec { } it("Views should align to edges within readable margins") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == view.superview!.readableContentGuide.edges } @@ -80,7 +80,7 @@ final class ViewLayoutGuideSpec: QuickSpec { } it("Views should center within readable margins") { - constrain(view) { view in + cg_constrain(view) { view in view.center == view.superview!.readableContentGuide.center view.width == 200 @@ -114,7 +114,7 @@ final class SafeAreaLayoutGuideSpec: QuickSpec { } it("Views should align to safe area edges") { - constrain(view) { view in + cg_constrain(view) { view in view.edges == view.superview!.safeAreaLayoutGuide.edges } @@ -127,7 +127,7 @@ final class SafeAreaLayoutGuideSpec: QuickSpec { } it("View should center in safe area") { - constrain(view) { view in + cg_constrain(view) { view in view.center == view.superview!.safeAreaLayoutGuide.center view.width == 200 view.height == 200 diff --git a/CartographyTests/ViewProxyTests.swift b/CartographyTests/ViewProxyTests.swift index bfbf126..275501c 100644 --- a/CartographyTests/ViewProxyTests.swift +++ b/CartographyTests/ViewProxyTests.swift @@ -20,7 +20,7 @@ final class ViewProxyTestsSpec: QuickSpec { let view: UIView = UIView(frame: .zero) - constrain(view) { testingView in + cg_constrain(view) { testingView in if #available(iOS 11, *), #available(tvOS 11, *) { context("When running on iOS 11+ devices") { it("safeArea should be SafeAreaLayoutGuide") {