Skip to content

Commit 5e72da6

Browse files
committed
Tidy up constraints for less crashers and less issues in Xcode 9
1 parent bf56075 commit 5e72da6

12 files changed

Lines changed: 66 additions & 111 deletions

Masonry/MASConstraint.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,9 @@
134134
- (MASConstraint *)centerY;
135135
- (MASConstraint *)baseline;
136136

137-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
138-
139137
- (MASConstraint *)firstBaseline;
140138
- (MASConstraint *)lastBaseline;
141139

142-
#endif
143-
144140
#if TARGET_OS_IPHONE || TARGET_OS_TV
145141

146142
- (MASConstraint *)leftMargin;

Masonry/MASConstraint.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,13 @@ - (MASConstraint *)baseline {
215215
return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
216216
}
217217

218-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
219-
220218
- (MASConstraint *)firstBaseline {
221219
return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline];
222220
}
223221
- (MASConstraint *)lastBaseline {
224222
return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline];
225223
}
226224

227-
#endif
228-
229225
#if TARGET_OS_IPHONE || TARGET_OS_TV
230226

231227
- (MASConstraint *)leftMargin {

Masonry/MASConstraintMaker.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ typedef NS_OPTIONS(NSInteger, MASAttribute) {
2121
MASAttributeCenterX = 1 << NSLayoutAttributeCenterX,
2222
MASAttributeCenterY = 1 << NSLayoutAttributeCenterY,
2323
MASAttributeBaseline = 1 << NSLayoutAttributeBaseline,
24-
25-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
26-
24+
2725
MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline,
2826
MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline,
2927

30-
#endif
31-
3228
#if TARGET_OS_IPHONE || TARGET_OS_TV
3329

3430
MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin,
@@ -67,13 +63,9 @@ typedef NS_OPTIONS(NSInteger, MASAttribute) {
6763
@property (nonatomic, strong, readonly) MASConstraint *centerY;
6864
@property (nonatomic, strong, readonly) MASConstraint *baseline;
6965

70-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
71-
7266
@property (nonatomic, strong, readonly) MASConstraint *firstBaseline;
7367
@property (nonatomic, strong, readonly) MASConstraint *lastBaseline;
7468

75-
#endif
76-
7769
#if TARGET_OS_IPHONE || TARGET_OS_TV
7870

7971
@property (nonatomic, strong, readonly) MASConstraint *leftMargin;

Masonry/MASConstraintMaker.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs {
7878
__unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading
7979
| MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX
8080
| MASAttributeCenterY | MASAttributeBaseline
81-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
8281
| MASAttributeFirstBaseline | MASAttributeLastBaseline
83-
#endif
8482
#if TARGET_OS_IPHONE || TARGET_OS_TV
8583
| MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin
8684
| MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins
@@ -103,14 +101,9 @@ - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs {
103101
if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX];
104102
if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY];
105103
if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline];
106-
107-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
108-
109104
if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline];
110105
if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline];
111106

112-
#endif
113-
114107
#if TARGET_OS_IPHONE || TARGET_OS_TV
115108

116109
if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin];
@@ -192,8 +185,6 @@ - (MASConstraint *)baseline {
192185
};
193186
}
194187

195-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
196-
197188
- (MASConstraint *)firstBaseline {
198189
return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline];
199190
}
@@ -202,9 +193,6 @@ - (MASConstraint *)lastBaseline {
202193
return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline];
203194
}
204195

205-
#endif
206-
207-
208196
#if TARGET_OS_IPHONE || TARGET_OS_TV
209197

210198
- (MASConstraint *)leftMargin {

Masonry/NSLayoutConstraint+MASDebugAdditions.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@ + (NSDictionary *)layoutAttributeDescriptionsByValue {
4343
@(NSLayoutAttributeCenterX) : @"centerX",
4444
@(NSLayoutAttributeCenterY) : @"centerY",
4545
@(NSLayoutAttributeBaseline) : @"baseline",
46-
47-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
4846
@(NSLayoutAttributeFirstBaseline) : @"firstBaseline",
4947
@(NSLayoutAttributeLastBaseline) : @"lastBaseline",
50-
#endif
51-
48+
5249
#if TARGET_OS_IPHONE || TARGET_OS_TV
5350
@(NSLayoutAttributeLeftMargin) : @"leftMargin",
5451
@(NSLayoutAttributeRightMargin) : @"rightMargin",

Masonry/View+MASAdditions.h

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@
3232
@property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline;
3333
@property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr);
3434

35-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
36-
3735
@property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline;
3836
@property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline;
3937

40-
#endif
41-
4238
#if TARGET_OS_IPHONE || TARGET_OS_TV
4339

4440
@property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
@@ -50,22 +46,17 @@
5046
@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
5147
@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;
5248

53-
#endif
54-
55-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)
56-
57-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide;
58-
59-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeading;
60-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTrailing;
61-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft;
62-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight;
63-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop;
64-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom;
65-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideWidth;
66-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideHeight;
67-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterX;
68-
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterY;
49+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide NS_AVAILABLE_IOS(11.0);
50+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeading NS_AVAILABLE_IOS(11.0);
51+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTrailing NS_AVAILABLE_IOS(11.0);
52+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft NS_AVAILABLE_IOS(11.0);
53+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight NS_AVAILABLE_IOS(11.0);
54+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop NS_AVAILABLE_IOS(11.0);
55+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom NS_AVAILABLE_IOS(11.0);
56+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideWidth NS_AVAILABLE_IOS(11.0);
57+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideHeight NS_AVAILABLE_IOS(11.0);
58+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterX NS_AVAILABLE_IOS(11.0);
59+
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterY NS_AVAILABLE_IOS(11.0);
6960

7061
#endif
7162

Masonry/View+MASAdditions.m

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,13 @@ - (MASViewAttribute *)mas_baseline {
8787
};
8888
}
8989

90-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
91-
9290
- (MASViewAttribute *)mas_firstBaseline {
9391
return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline];
9492
}
9593
- (MASViewAttribute *)mas_lastBaseline {
9694
return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline];
9795
}
9896

99-
#endif
100-
10197
#if TARGET_OS_IPHONE || TARGET_OS_TV
10298

10399
- (MASViewAttribute *)mas_leftMargin {
@@ -132,10 +128,6 @@ - (MASViewAttribute *)mas_centerYWithinMargins {
132128
return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins];
133129
}
134130

135-
#endif
136-
137-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)
138-
139131
- (MASViewAttribute *)mas_safeAreaLayoutGuide {
140132
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeNotAnAttribute];
141133
}

Masonry/View+MASShorthandAdditions.h

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@
2929
@property (nonatomic, strong, readonly) MASViewAttribute *baseline;
3030
@property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr);
3131

32-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
33-
3432
@property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline;
3533
@property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline;
3634

37-
#endif
38-
3935
#if TARGET_OS_IPHONE || TARGET_OS_TV
4036

4137
@property (nonatomic, strong, readonly) MASViewAttribute *leftMargin;
@@ -49,12 +45,18 @@
4945

5046
#endif
5147

52-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)
48+
#if TARGET_OS_IPHONE || TARGET_OS_TV
5349

54-
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop;
55-
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom;
56-
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft;
57-
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight;
50+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeading NS_AVAILABLE_IOS(11.0);
51+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTrailing NS_AVAILABLE_IOS(11.0);
52+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft NS_AVAILABLE_IOS(11.0);
53+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight NS_AVAILABLE_IOS(11.0);
54+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop NS_AVAILABLE_IOS(11.0);
55+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom NS_AVAILABLE_IOS(11.0);
56+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideWidth NS_AVAILABLE_IOS(11.0);
57+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideHeight NS_AVAILABLE_IOS(11.0);
58+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideCenterX NS_AVAILABLE_IOS(11.0);
59+
@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideCenterY NS_AVAILABLE_IOS(11.0);
5860

5961
#endif
6062

@@ -69,6 +71,11 @@
6971
return [self mas_##attr]; \
7072
}
7173

74+
#define MAS_ATTR_FORWARD_AVAILABLE(attr, available) \
75+
- (MASViewAttribute *)attr available { \
76+
return [self mas_##attr]; \
77+
}
78+
7279
@implementation MAS_VIEW (MASShorthandAdditions)
7380

7481
MAS_ATTR_FORWARD(top);
@@ -83,13 +90,9 @@ MAS_ATTR_FORWARD(centerX);
8390
MAS_ATTR_FORWARD(centerY);
8491
MAS_ATTR_FORWARD(baseline);
8592

86-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
87-
8893
MAS_ATTR_FORWARD(firstBaseline);
8994
MAS_ATTR_FORWARD(lastBaseline);
9095

91-
#endif
92-
9396
#if TARGET_OS_IPHONE || TARGET_OS_TV
9497

9598
MAS_ATTR_FORWARD(leftMargin);
@@ -101,14 +104,16 @@ MAS_ATTR_FORWARD(trailingMargin);
101104
MAS_ATTR_FORWARD(centerXWithinMargins);
102105
MAS_ATTR_FORWARD(centerYWithinMargins);
103106

104-
#endif
105-
106-
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)
107-
108-
MAS_ATTR_FORWARD(safeAreaLayoutGuideTop);
109-
MAS_ATTR_FORWARD(safeAreaLayoutGuideBottom);
110-
MAS_ATTR_FORWARD(safeAreaLayoutGuideLeft);
111-
MAS_ATTR_FORWARD(safeAreaLayoutGuideRight);
107+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeading, NS_AVAILABLE_IOS(11.0));
108+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTrailing, NS_AVAILABLE_IOS(11.0));
109+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeft, NS_AVAILABLE_IOS(11.0));
110+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideRight, NS_AVAILABLE_IOS(11.0));
111+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTop, NS_AVAILABLE_IOS(11.0));
112+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideBottom, NS_AVAILABLE_IOS(11.0));
113+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideWidth, NS_AVAILABLE_IOS(11.0));
114+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideHeight, NS_AVAILABLE_IOS(11.0));
115+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterX, NS_AVAILABLE_IOS(11.0));
116+
MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterY, NS_AVAILABLE_IOS(11.0));
112117

113118
#endif
114119

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- Expecta (1.0.5)
3-
- Masonry (1.0.2)
3+
- Masonry (1.1.0)
44

55
DEPENDENCIES:
66
- Expecta
@@ -12,7 +12,7 @@ EXTERNAL SOURCES:
1212

1313
SPEC CHECKSUMS:
1414
Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe
15-
Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e
15+
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
1616

1717
PODFILE CHECKSUM: a30c350a250a8af6afde1caabae52ede1d76714b
1818

Pods/Local Podspecs/Masonry.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)