Skip to content

Commit 7b39081

Browse files
author
Luc Dion
committed
Update for tvOS and macOS
1 parent 2de2708 commit 7b39081

File tree

9 files changed

+51
-27
lines changed

9 files changed

+51
-27
lines changed

Example/PinLayoutSample.xcodeproj/xcshareddata/xcschemes/PinLayoutSample.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0940"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

PinLayout.xcodeproj/project.pbxproj

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
DF1A5D432084CFD600725EF5 /* TypesImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2475B6CE1FC37C570054CADD /* TypesImpl.swift */; };
7777
DF1A5D442084CFD600725EF5 /* UIView+LTR.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2475B6D01FC37C8C0054CADD /* UIView+LTR.swift */; };
7878
DF1E39B520482B200002D0AA /* PinSafeAreaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF1E39B420482B1F0002D0AA /* PinSafeAreaTests.swift */; };
79+
DF28022420C2B13800A1833B /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFF222CC20B999BD00AC2A84 /* Types.swift */; };
80+
DF28022520C2B13900A1833B /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFF222CC20B999BD00AC2A84 /* Types.swift */; };
81+
DF28022620C2B15A00A1833B /* Types+Description.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFF222CE20B99A6600AC2A84 /* Types+Description.swift */; };
82+
DF28022720C2B15B00A1833B /* Types+Description.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFF222CE20B99A6600AC2A84 /* Types+Description.swift */; };
7983
DF7A36BD1E918301000F9856 /* PinEdgesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF7A36BC1E918301000F9856 /* PinEdgesSpec.swift */; };
8084
DFABC01F208781A900CB6494 /* Types+Appkit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFABC01E208781A900CB6494 /* Types+Appkit.swift */; };
8185
DFABC022208781ED00CB6494 /* Types+UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFABC020208781C700CB6494 /* Types+UIKit.swift */; };
@@ -590,7 +594,7 @@
590594
isa = PBXProject;
591595
attributes = {
592596
LastSwiftUpdateCheck = 0930;
593-
LastUpgradeCheck = 0900;
597+
LastUpgradeCheck = 0940;
594598
ORGANIZATIONNAME = mcswiftlayyout.mirego.com;
595599
TargetAttributes = {
596600
244DF2F71EF46C500090508B = {
@@ -808,8 +812,10 @@
808812
files = (
809813
243C62081FC37F6C0082C327 /* PinLayoutImpl+Warning.swift in Sources */,
810814
DFF222B420B877F900AC2A84 /* PinLayoutObjCImpl.swift in Sources */,
815+
DF28022720C2B15B00A1833B /* Types+Description.swift in Sources */,
811816
DFF222B220B877F600AC2A84 /* PinLayoutObjC.swift in Sources */,
812817
24D18D261F3E5EA5008129EF /* Pin.swift in Sources */,
818+
DF28022420C2B13800A1833B /* Types.swift in Sources */,
813819
DF1A5D362084CFC100725EF5 /* NSView+PinLayout.swift in Sources */,
814820
243C62041FC37F680082C327 /* PinLayoutImpl.swift in Sources */,
815821
243C62071FC37F6C0082C327 /* PinLayoutImpl+Relative.swift in Sources */,
@@ -914,8 +920,10 @@
914920
files = (
915921
DF1A5D3F2084CFD600725EF5 /* PinLayoutImpl+Warning.swift in Sources */,
916922
DFF222B320B877F800AC2A84 /* PinLayoutObjCImpl.swift in Sources */,
923+
DF28022620C2B15A00A1833B /* Types+Description.swift in Sources */,
917924
DFF222B120B877F400AC2A84 /* PinLayoutObjC.swift in Sources */,
918925
DF1A5D3B2084CFD600725EF5 /* PinLayoutImpl.swift in Sources */,
926+
DF28022520C2B13900A1833B /* Types.swift in Sources */,
919927
DF1A5D412084CFD600725EF5 /* Coordinates.swift in Sources */,
920928
DF1A5D422084CFD600725EF5 /* Percent.swift in Sources */,
921929
DF1A5D3E2084CFD600725EF5 /* PinLayoutImpl+Relative.swift in Sources */,
@@ -982,7 +990,7 @@
982990
isa = XCBuildConfiguration;
983991
buildSettings = {
984992
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
985-
CODE_SIGN_IDENTITY = "iPhone Developer";
993+
CODE_SIGN_IDENTITY = "";
986994
DEFINES_MODULE = YES;
987995
DEVELOPMENT_TEAM = "";
988996
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -1039,13 +1047,15 @@
10391047
CLANG_WARN_BOOL_CONVERSION = YES;
10401048
CLANG_WARN_COMMA = YES;
10411049
CLANG_WARN_CONSTANT_CONVERSION = YES;
1050+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
10421051
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
10431052
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
10441053
CLANG_WARN_EMPTY_BODY = YES;
10451054
CLANG_WARN_ENUM_CONVERSION = YES;
10461055
CLANG_WARN_INFINITE_RECURSION = YES;
10471056
CLANG_WARN_INT_CONVERSION = YES;
10481057
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
1058+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
10491059
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
10501060
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
10511061
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -1102,13 +1112,15 @@
11021112
CLANG_WARN_BOOL_CONVERSION = YES;
11031113
CLANG_WARN_COMMA = YES;
11041114
CLANG_WARN_CONSTANT_CONVERSION = YES;
1115+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
11051116
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
11061117
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
11071118
CLANG_WARN_EMPTY_BODY = YES;
11081119
CLANG_WARN_ENUM_CONVERSION = YES;
11091120
CLANG_WARN_INFINITE_RECURSION = YES;
11101121
CLANG_WARN_INT_CONVERSION = YES;
11111122
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
1123+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
11121124
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
11131125
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
11141126
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -1149,7 +1161,7 @@
11491161
isa = XCBuildConfiguration;
11501162
buildSettings = {
11511163
CLANG_ENABLE_MODULES = YES;
1152-
CODE_SIGN_IDENTITY = "iPhone Developer";
1164+
CODE_SIGN_IDENTITY = "";
11531165
DEFINES_MODULE = YES;
11541166
DEVELOPMENT_TEAM = "";
11551167
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -1279,7 +1291,7 @@
12791291
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
12801292
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
12811293
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
1282-
CODE_SIGN_IDENTITY = "Mac Developer";
1294+
CODE_SIGN_IDENTITY = "";
12831295
CODE_SIGN_STYLE = Automatic;
12841296
COMBINE_HIDPI_IMAGES = YES;
12851297
DEFINES_MODULE = YES;
@@ -1311,7 +1323,7 @@
13111323
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
13121324
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
13131325
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
1314-
CODE_SIGN_IDENTITY = "Mac Developer";
1326+
CODE_SIGN_IDENTITY = "";
13151327
CODE_SIGN_STYLE = Automatic;
13161328
COMBINE_HIDPI_IMAGES = YES;
13171329
DEFINES_MODULE = YES;

PinLayout.xcodeproj/xcshareddata/xcschemes/PinLayout-iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0940"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

PinLayout.xcodeproj/xcshareddata/xcschemes/PinLayout-macOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "0940"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

PinLayout.xcodeproj/xcshareddata/xcschemes/PinLayout-tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0940"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Sources/Impl/PinLayoutImpl+WrapContent.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ import AppKit
2525

2626
extension PinLayoutImpl {
2727
func wrapContent() -> PinLayout {
28-
return wrapContent(.all, padding: .zero, { return "wrapContent()" })
28+
return wrapContent(.all, padding: PEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), { return "wrapContent()" })
2929
}
3030

3131
func wrapContent(padding: CGFloat) -> PinLayout {
32-
return wrapContent(.all, padding: UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding), { return "wrapContent(padding: \(padding)" })
32+
return wrapContent(.all, padding: PEdgeInsets(top: padding, left: padding, bottom: padding, right: padding), { return "wrapContent(padding: \(padding)" })
3333
}
3434

35-
func wrapContent(padding: UIEdgeInsets) -> PinLayout {
35+
func wrapContent(padding: PEdgeInsets) -> PinLayout {
3636
return wrapContent(.all, padding: padding, { return "wrapContent(padding: \(insetsDescription(padding))" })
3737
}
3838

3939
func wrapContent(_ type: WrapType) -> PinLayout {
40-
return wrapContent(type, padding: .zero, { return "wrapContent(\(type.description)" })
40+
return wrapContent(type, padding: PEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), { return "wrapContent(\(type.description)" })
4141
}
4242

4343
func wrapContent(_ type: WrapType, padding: CGFloat) -> PinLayout {
44-
return wrapContent(type, padding: UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding), { return "wrapContent(\(type.description), padding: \(padding)" })
44+
return wrapContent(type, padding: PEdgeInsets(top: padding, left: padding, bottom: padding, right: padding), { return "wrapContent(\(type.description), padding: \(padding)" })
4545
}
4646

47-
func wrapContent(_ type: WrapType, padding: UIEdgeInsets) -> PinLayout {
47+
func wrapContent(_ type: WrapType, padding: PEdgeInsets) -> PinLayout {
4848
return wrapContent(type, padding: padding, { return "wrapContent(\(type.description), padding: \(insetsDescription(padding))" })
4949
}
5050

51-
private func wrapContent(_ type: WrapType, padding: UIEdgeInsets, _ context: Context) -> PinLayout {
51+
private func wrapContent(_ type: WrapType, padding: PEdgeInsets, _ context: Context) -> PinLayout {
5252
let subviews = view.subviews
5353
guard !subviews.isEmpty else { return self }
5454
let firstViewFrame = subviews[0].frame
@@ -57,7 +57,7 @@ extension PinLayoutImpl {
5757
var minY = firstViewFrame.minY
5858
var maxY = firstViewFrame.maxY
5959

60-
for var i in 1..<subviews.count {
60+
for i in 1..<subviews.count {
6161
let frame = subviews[i].frame
6262
if frame.minX < minX {
6363
minX = frame.minX

Sources/PinLayout.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ public protocol PinLayout {
325325
- Parameters:
326326
- padding: Specify a padding using an UIEdgeInsets.
327327
*/
328+
#if os(iOS) || os(tvOS)
328329
@discardableResult func wrapContent(padding: UIEdgeInsets) -> PinLayout
330+
#elseif os(macOS)
331+
@discardableResult func wrapContent(padding: NSEdgeInsets) -> PinLayout
332+
#endif
329333

330334
/**
331335
Adjust the view's width AND/OR height to wrap all its subviews.
@@ -349,7 +353,12 @@ public protocol PinLayout {
349353
- type: Specify the wrap type (.all, .horizontally, .vertically)
350354
- padding: Specify a padding using an UIEdgeInsets.
351355
*/
356+
#if os(iOS) || os(tvOS)
352357
@discardableResult func wrapContent(_ type: WrapType, padding: UIEdgeInsets) -> PinLayout
358+
#elseif os(macOS)
359+
@discardableResult func wrapContent(_ type: WrapType, padding: NSEdgeInsets) -> PinLayout
360+
#endif
361+
353362

354363
/**
355364
Set the view aspect ratio.

Sources/Types+Description.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
// Copyright © 2018 mcswiftlayyout.mirego.com. All rights reserved.
77
//
88

9-
import Foundation
9+
#if os(iOS) || os(tvOS)
10+
import UIKit
11+
#else
12+
import AppKit
13+
#endif
1014

1115
extension HorizontalAlign {
1216
var description: String {

Tests/Common/WrapContentSpec.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,12 @@ class WrapContentSpec: QuickSpec {
279279
expect(aViewChild3.frame).to(equal(CGRect(x: 360.0, y: 30.0, width: 60.0, height: 60.0)))
280280
}
281281

282-
283282
it("wrap all + padding UIEdgeInsets") {
284283
aView.frame = CGRect(x: 20, y: 10, width: 200, height: 100)
285284
aViewChild.frame = CGRect(x: 160, y: 120, width: 100, height: 40)
286285
aViewChild2.frame = CGRect(x: 260, y: 120, width: 60, height: 60)
287286
aViewChild3.frame = CGRect(x: 360, y: 140, width: 60, height: 60)
288-
aView.pin.wrapContent(padding: UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
287+
aView.pin.wrapContent(padding: PEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
289288
expect(aView.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 320.0, height: 120.0)))
290289
expect(aViewChild.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 100.0, height: 40.0)))
291290
expect(aViewChild2.frame).to(equal(CGRect(x: 120.0, y: 10.0, width: 60.0, height: 60.0)))
@@ -297,20 +296,20 @@ class WrapContentSpec: QuickSpec {
297296
aViewChild.frame = CGRect(x: 160, y: 120, width: 100, height: 40)
298297
aViewChild2.frame = CGRect(x: 260, y: 120, width: 60, height: 60)
299298
aViewChild3.frame = CGRect(x: 360, y: 140, width: 60, height: 60)
300-
aView.pin.wrapContent(.all, padding: UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
299+
aView.pin.wrapContent(.all, padding: PEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
301300
expect(aView.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 320.0, height: 120.0)))
302301
expect(aViewChild.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 100.0, height: 40.0)))
303302
expect(aViewChild2.frame).to(equal(CGRect(x: 120.0, y: 10.0, width: 60.0, height: 60.0)))
304303
expect(aViewChild3.frame).to(equal(CGRect(x: 220.0, y: 30.0, width: 60.0, height: 60.0)))
305304

306305
}
307306

308-
it("wrap horizontally + padding UIEdgeInsets") {
307+
it("wrap horizontally + padding PEdgeInsets") {
309308
aView.frame = CGRect(x: 20, y: 10, width: 200, height: 100)
310309
aViewChild.frame = CGRect(x: 160, y: 120, width: 100, height: 40)
311310
aViewChild2.frame = CGRect(x: 260, y: 120, width: 60, height: 60)
312311
aViewChild3.frame = CGRect(x: 360, y: 140, width: 60, height: 60)
313-
aView.pin.wrapContent(.horizontally, padding: UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
312+
aView.pin.wrapContent(.horizontally, padding: PEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
314313
expect(aView.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 320.0, height: 100.0)))
315314
expect(aViewChild.frame).to(equal(CGRect(x: 20.0, y: 120.0, width: 100.0, height: 40.0)))
316315
expect(aViewChild2.frame).to(equal(CGRect(x: 120.0, y: 120.0, width: 60.0, height: 60.0)))
@@ -319,25 +318,25 @@ class WrapContentSpec: QuickSpec {
319318
}
320319

321320

322-
it("wrap vertically + padding UIEdgeInsets") {
321+
it("wrap vertically + padding PEdgeInsets") {
323322
aView.frame = CGRect(x: 20, y: 10, width: 200, height: 100)
324323
aViewChild.frame = CGRect(x: 160, y: 120, width: 100, height: 40)
325324
aViewChild2.frame = CGRect(x: 260, y: 120, width: 60, height: 60)
326325
aViewChild3.frame = CGRect(x: 360, y: 140, width: 60, height: 60)
327-
aView.pin.wrapContent(.vertically, padding: UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
326+
aView.pin.wrapContent(.vertically, padding: PEdgeInsets(top: 10, left: 20, bottom: 30, right: 40))
328327
expect(aView.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 200.0, height: 120.0)))
329328
expect(aViewChild.frame).to(equal(CGRect(x: 160.0, y: 10.0, width: 100.0, height: 40.0)))
330329
expect(aViewChild2.frame).to(equal(CGRect(x: 260.0, y: 10.0, width: 60.0, height: 60.0)))
331330
expect(aViewChild3.frame).to(equal(CGRect(x: 360.0, y: 30.0, width: 60.0, height: 60.0)))
332331

333332
}
334333

335-
it("wrap all + negative padding UIEdgeInsets") {
334+
it("wrap all + negative padding PEdgeInsets") {
336335
aView.frame = CGRect(x: 20, y: 10, width: 200, height: 100)
337336
aViewChild.frame = CGRect(x: 160, y: 120, width: 100, height: 40)
338337
aViewChild2.frame = CGRect(x: 260, y: 120, width: 60, height: 60)
339338
aViewChild3.frame = CGRect(x: 360, y: 140, width: 60, height: 60)
340-
aView.pin.wrapContent(.all, padding: UIEdgeInsets(top: -10, left: -20, bottom: -30, right: -40))
339+
aView.pin.wrapContent(.all, padding: PEdgeInsets(top: -10, left: -20, bottom: -30, right: -40))
341340
expect(aView.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 200.0, height: 40.0)))
342341
expect(aViewChild.frame).to(equal(CGRect(x: -20.0, y: -10.0, width: 100.0, height: 40.0)))
343342
expect(aViewChild2.frame).to(equal(CGRect(x: 80.0, y: -10.0, width: 60.0, height: 60.0)))

0 commit comments

Comments
 (0)