Skip to content

Commit 117d080

Browse files
Merge branch 'swift5'
2 parents aa81e9a + e1bc622 commit 117d080

File tree

15 files changed

+120
-69
lines changed

15 files changed

+120
-69
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: objective-c
2-
osx_image: xcode9
2+
osx_image: xcode10.2
33
script:
44
- ./script/cibuild

LayoutExpressions.xcodeproj/project.pbxproj

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@
451451
developmentRegion = English;
452452
hasScannedForEncodings = 0;
453453
knownRegions = (
454+
English,
454455
en,
455456
);
456457
mainGroup = AACF91AF194008D300748874;
@@ -614,6 +615,7 @@
614615
isa = XCBuildConfiguration;
615616
buildSettings = {
616617
APPLICATION_EXTENSION_API_ONLY = YES;
618+
CODE_SIGN_IDENTITY = "";
617619
DEBUG_INFORMATION_FORMAT = dwarf;
618620
DEFINES_MODULE = YES;
619621
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -629,6 +631,7 @@
629631
PRODUCT_NAME = LayoutExpressions;
630632
SDKROOT = appletvos;
631633
SKIP_INSTALL = YES;
634+
SWIFT_VERSION = 5.0;
632635
TARGETED_DEVICE_FAMILY = 3;
633636
TVOS_DEPLOYMENT_TARGET = 9.0;
634637
};
@@ -638,6 +641,7 @@
638641
isa = XCBuildConfiguration;
639642
buildSettings = {
640643
APPLICATION_EXTENSION_API_ONLY = YES;
644+
CODE_SIGN_IDENTITY = "";
641645
COPY_PHASE_STRIP = NO;
642646
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
643647
DEFINES_MODULE = YES;
@@ -653,6 +657,7 @@
653657
PRODUCT_NAME = LayoutExpressions;
654658
SDKROOT = appletvos;
655659
SKIP_INSTALL = YES;
660+
SWIFT_VERSION = 5.0;
656661
TARGETED_DEVICE_FAMILY = 3;
657662
TVOS_DEPLOYMENT_TARGET = 9.0;
658663
};
@@ -662,6 +667,7 @@
662667
isa = XCBuildConfiguration;
663668
buildSettings = {
664669
CLANG_ENABLE_MODULES = YES;
670+
CODE_SIGN_IDENTITY = "";
665671
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
666672
GCC_PREPROCESSOR_DEFINITIONS = (
667673
"DEBUG=1",
@@ -673,19 +679,24 @@
673679
PRODUCT_NAME = "$(TARGET_NAME)";
674680
SDKROOT = appletvos;
675681
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
682+
SWIFT_VERSION = 5.0;
683+
TARGETED_DEVICE_FAMILY = 3;
676684
};
677685
name = Debug;
678686
};
679687
AA6E63861EF2DCC0000669CD /* Release */ = {
680688
isa = XCBuildConfiguration;
681689
buildSettings = {
682690
CLANG_ENABLE_MODULES = YES;
691+
CODE_SIGN_IDENTITY = "";
683692
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
684693
INFOPLIST_FILE = LayoutExpressionsTests/Info.plist;
685694
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
686695
METAL_ENABLE_DEBUG_INFO = NO;
687696
PRODUCT_NAME = "$(TARGET_NAME)";
688697
SDKROOT = appletvos;
698+
SWIFT_VERSION = 5.0;
699+
TARGETED_DEVICE_FAMILY = 3;
689700
};
690701
name = Release;
691702
};
@@ -706,7 +717,6 @@
706717
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
707718
CLANG_WARN_UNREACHABLE_CODE = YES;
708719
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
709-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
710720
COPY_PHASE_STRIP = NO;
711721
CURRENT_PROJECT_VERSION = 1;
712722
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -725,12 +735,12 @@
725735
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
726736
GCC_WARN_UNUSED_FUNCTION = YES;
727737
GCC_WARN_UNUSED_VARIABLE = YES;
728-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
738+
IPHONEOS_DEPLOYMENT_TARGET = "";
729739
METAL_ENABLE_DEBUG_INFO = YES;
730740
ONLY_ACTIVE_ARCH = YES;
731741
SDKROOT = iphoneos;
732742
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
733-
SWIFT_VERSION = 3.0;
743+
SWIFT_VERSION = 5.0;
734744
TARGETED_DEVICE_FAMILY = "1,2";
735745
VERSIONING_SYSTEM = "apple-generic";
736746
VERSION_INFO_PREFIX = "";
@@ -754,7 +764,6 @@
754764
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
755765
CLANG_WARN_UNREACHABLE_CODE = YES;
756766
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
757-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
758767
COPY_PHASE_STRIP = YES;
759768
CURRENT_PROJECT_VERSION = 1;
760769
ENABLE_NS_ASSERTIONS = NO;
@@ -767,10 +776,10 @@
767776
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
768777
GCC_WARN_UNUSED_FUNCTION = YES;
769778
GCC_WARN_UNUSED_VARIABLE = YES;
770-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
779+
IPHONEOS_DEPLOYMENT_TARGET = "";
771780
METAL_ENABLE_DEBUG_INFO = NO;
772781
SDKROOT = iphoneos;
773-
SWIFT_VERSION = 3.0;
782+
SWIFT_VERSION = 5.0;
774783
TARGETED_DEVICE_FAMILY = "1,2";
775784
VALIDATE_PRODUCT = YES;
776785
VERSIONING_SYSTEM = "apple-generic";
@@ -789,11 +798,13 @@
789798
DYLIB_INSTALL_NAME_BASE = "@rpath";
790799
INFOPLIST_FILE = LayoutExpressions/Info.plist;
791800
INSTALL_PATH = "";
801+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
792802
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
793803
PRODUCT_BUNDLE_IDENTIFIER = com.stevebrambilla.LayoutExpressions;
794804
PRODUCT_NAME = LayoutExpressions;
795805
SKIP_INSTALL = YES;
796806
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
807+
SWIFT_VERSION = 5.0;
797808
};
798809
name = Debug;
799810
};
@@ -808,10 +819,12 @@
808819
DYLIB_INSTALL_NAME_BASE = "@rpath";
809820
INFOPLIST_FILE = LayoutExpressions/Info.plist;
810821
INSTALL_PATH = "";
822+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
811823
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
812824
PRODUCT_BUNDLE_IDENTIFIER = com.stevebrambilla.LayoutExpressions;
813825
PRODUCT_NAME = LayoutExpressions;
814826
SKIP_INSTALL = YES;
827+
SWIFT_VERSION = 5.0;
815828
};
816829
name = Release;
817830
};
@@ -829,6 +842,7 @@
829842
METAL_ENABLE_DEBUG_INFO = YES;
830843
PRODUCT_NAME = "$(TARGET_NAME)";
831844
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
845+
SWIFT_VERSION = 5.0;
832846
};
833847
name = Debug;
834848
};
@@ -841,6 +855,7 @@
841855
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
842856
METAL_ENABLE_DEBUG_INFO = NO;
843857
PRODUCT_NAME = "$(TARGET_NAME)";
858+
SWIFT_VERSION = 5.0;
844859
};
845860
name = Release;
846861
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

LayoutExpressions/AxisExpression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public struct AxisExpression<Axis: AxisProtocol, Constant: ConstantProtocol>: Di
5353
let constraint = AnchorConstraints.constraintForRelation(relation: relation, leftAnchor: leftAnchor, rightAnchor: rightAnchor, constant: constant)
5454

5555
if let priority = priority {
56-
constraint.priority = priority
56+
constraint.priority = priority.layoutPriority
5757
}
5858

5959
return constraint

LayoutExpressions/CenterExpression.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public struct CenterExpression<Offset: OffsetProtocol>: ExpressionProtocol {
3636
let yConstraint = AnchorConstraints.constraintForRelation(relation: relation, leftAnchor: lhs.centerYAnchor, rightAnchor: rhs.centerYAnchor, constant: offset.vertical)
3737

3838
if let priority = priority {
39-
xConstraint.priority = priority
40-
yConstraint.priority = priority
39+
xConstraint.priority = priority.layoutPriority
40+
yConstraint.priority = priority.layoutPriority
4141
}
4242

4343
return [xConstraint, yConstraint]

LayoutExpressions/DimensionExpression.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public struct DimensionExpression<Multiplier: MultiplierProtocol, Constant: Cons
3232
let constraint = DimensionConstraints.constraintForRelation(relation: relation, leftDimension: leftDimension, rightDimension: rightDimension, multiplier: multiplier, constant: constant)
3333

3434
if let priority = priority {
35-
constraint.priority = priority
35+
constraint.priority = priority.layoutPriority
3636
}
3737

3838
return constraint
@@ -71,7 +71,7 @@ public struct ConstantDimensionExpression: DistinctExpressionType {
7171
let constraint = DimensionConstraints.constraintForRelation(relation: relation, leftDimension: leftDimension, constant: constantValue)
7272

7373
if let priority = priority {
74-
constraint.priority = priority
74+
constraint.priority = priority.layoutPriority
7575
}
7676

7777
return constraint

LayoutExpressions/EdgesExpression.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public struct EdgesExpression<Insets: InsetsProtocol>: ExpressionProtocol {
4444
let rightConstraint = AnchorConstraints.constraintForRelation(relation: relation, leftAnchor: lhs.rightAnchor, rightAnchor: rhs.rightAnchor, constant: -insets.right)
4545

4646
if let priority = priority {
47-
topConstraint.priority = priority
48-
leftConstraint.priority = priority
49-
bottomConstraint.priority = priority
50-
rightConstraint.priority = priority
47+
topConstraint.priority = priority.layoutPriority
48+
leftConstraint.priority = priority.layoutPriority
49+
bottomConstraint.priority = priority.layoutPriority
50+
rightConstraint.priority = priority.layoutPriority
5151
}
5252

5353
return [topConstraint, leftConstraint, bottomConstraint, rightConstraint]

LayoutExpressions/Evaluation.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,27 @@ public func evaluateLayoutExpressions(_ expressions: [ExpressionProtocol]) -> [N
2424
return acc + expression.evaluateAll()
2525
}
2626
}
27+
28+
/// Evaluates a distinct layout expression and activates the constraint.
29+
///
30+
/// The effect of this function is the same as setting the `isActive` property of the constraint to
31+
/// `true`.
32+
public func activateLayoutExpression(_ expression: DistinctExpressionType) {
33+
evaluateLayoutExpression(expression).isActive = true
34+
}
35+
36+
/// Evaluates a layout expression and activates its constraints.
37+
///
38+
/// The effect of this function is the same as setting the `isActive` property of the constraints to
39+
/// `true`.
40+
public func activateLayoutExpression(_ expression: ExpressionProtocol) {
41+
evaluateLayoutExpression(expression).activateConstraints()
42+
}
43+
44+
/// Evaluates multiple layout expressions and activates their constraints.
45+
///
46+
/// The effect of this function is the same as setting the `isActive` property of each constraint
47+
/// to `true`.
48+
public func activateLayoutExpressions(_ expressions: [ExpressionProtocol]) {
49+
evaluateLayoutExpressions(expressions).activateConstraints()
50+
}

LayoutExpressions/Priority.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ extension Priority {
1515
internal var isValid: Bool {
1616
return self >= 0 && self <= 1000
1717
}
18+
19+
internal var layoutPriority: UILayoutPriority {
20+
return UILayoutPriority(rawValue: self)
21+
}
1822
}
1923

2024
precedencegroup PrioritizationPrecedence {

LayoutExpressions/SizeExpression.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public struct SizeExpression<Size: SizeProtocol>: ExpressionProtocol {
4141
let heightConstraint = DimensionConstraints.constraintForRelation(relation: relation, leftDimension: lhs.heightAnchor, rightDimension: rhs.heightAnchor, multiplier: 1.0, constant: size.height)
4242

4343
if let priority = priority {
44-
widthConstraint.priority = priority
45-
heightConstraint.priority = priority
44+
widthConstraint.priority = priority.layoutPriority
45+
heightConstraint.priority = priority.layoutPriority
4646
}
4747

4848
return [widthConstraint, heightConstraint]
@@ -75,8 +75,8 @@ public struct ConstantSizeExpression: ExpressionProtocol {
7575
let heightConstraint = DimensionConstraints.constraintForRelation(relation: relation, leftDimension: lhs.heightAnchor, constant: size.height)
7676

7777
if let priority = priority {
78-
widthConstraint.priority = priority
79-
heightConstraint.priority = priority
78+
widthConstraint.priority = priority.layoutPriority
79+
heightConstraint.priority = priority.layoutPriority
8080
}
8181

8282
return [widthConstraint, heightConstraint]

0 commit comments

Comments
 (0)