Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Commit 642d828

Browse files
li-svartakpa1-linkedin
authored andcommitted
Added support for swift 5
1 parent c77e9bc commit 642d828

23 files changed

Lines changed: 70 additions & 60 deletions

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1
1+
5.0

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode9.3
2+
osx_image: xcode10.2
33
script: sh build.sh /tmp/LayoutKit
44
after_success:
55
- bash <(curl -s https://codecov.io/bash) -D /tmp/LayoutKit

LayoutKit.playground/Pages/TextView.xcplaygroundpage/Contents.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ rootView.backgroundColor = .white
88
let textString = "Hello World\nHello World\nHello World\nHello World\nHello World\n"
99
let attributedString1 = NSMutableAttributedString(
1010
string: textString,
11-
attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 15)])
11+
attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)])
1212
let attributedString2 = NSMutableAttributedString(
1313
string: textString,
14-
attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12)])
14+
attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 12)])
1515
attributedString1.append(attributedString2)
1616
let attributedText = Text.attributed(attributedString1)
1717

LayoutKit.xcodeproj/project.pbxproj

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,16 +1160,17 @@
11601160
TargetAttributes = {
11611161
0B2D09AF1D8735E1007E487C = {
11621162
CreatedOnToolsVersion = 8.0;
1163-
LastSwiftMigration = 0800;
1163+
LastSwiftMigration = 1020;
11641164
ProvisioningStyle = Automatic;
11651165
};
11661166
0BCB755E1D8720110065E02A = {
11671167
CreatedOnToolsVersion = 8.0;
1168-
LastSwiftMigration = 0800;
1168+
LastSwiftMigration = 1020;
11691169
ProvisioningStyle = Automatic;
11701170
};
11711171
0BCB75671D8720110065E02A = {
11721172
CreatedOnToolsVersion = 8.0;
1173+
LastSwiftMigration = 1020;
11731174
ProvisioningStyle = Automatic;
11741175
};
11751176
0BCB757B1D8721370065E02A = {
@@ -1190,18 +1191,21 @@
11901191
};
11911192
0BCB75B51D8723B30065E02A = {
11921193
CreatedOnToolsVersion = 8.0;
1193-
LastSwiftMigration = 0800;
1194+
LastSwiftMigration = 1020;
11941195
ProvisioningStyle = Automatic;
11951196
};
11961197
7EEA2AB5201D18F20077A088 = {
11971198
CreatedOnToolsVersion = 9.2;
11981199
ProvisioningStyle = Automatic;
11991200
};
1201+
7EECD00E2053916C003DC4B1 = {
1202+
LastSwiftMigration = 1020;
1203+
};
12001204
};
12011205
};
12021206
buildConfigurationList = 0BCB75571D871FC40065E02A /* Build configuration list for PBXProject "LayoutKit" */;
12031207
compatibilityVersion = "Xcode 3.2";
1204-
developmentRegion = English;
1208+
developmentRegion = en;
12051209
hasScannedForEncodings = 0;
12061210
knownRegions = (
12071211
en,
@@ -1730,6 +1734,7 @@
17301734
SDKROOT = iphoneos;
17311735
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
17321736
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1737+
SWIFT_VERSION = 5.0;
17331738
TARGETED_DEVICE_FAMILY = "1,2";
17341739
};
17351740
name = Debug;
@@ -1777,6 +1782,7 @@
17771782
PRODUCT_NAME = "$(TARGET_NAME)";
17781783
SDKROOT = iphoneos;
17791784
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1785+
SWIFT_VERSION = 5.0;
17801786
TARGETED_DEVICE_FAMILY = "1,2";
17811787
VALIDATE_PRODUCT = YES;
17821788
};
@@ -1812,7 +1818,7 @@
18121818
GCC_WARN_UNUSED_FUNCTION = YES;
18131819
GCC_WARN_UNUSED_VARIABLE = YES;
18141820
ONLY_ACTIVE_ARCH = YES;
1815-
SWIFT_VERSION = 4.1;
1821+
SWIFT_VERSION = 5.0;
18161822
};
18171823
name = Debug;
18181824
};
@@ -1845,7 +1851,7 @@
18451851
GCC_WARN_UNUSED_FUNCTION = YES;
18461852
GCC_WARN_UNUSED_VARIABLE = YES;
18471853
SWIFT_COMPILATION_MODE = wholemodule;
1848-
SWIFT_VERSION = 4.1;
1854+
SWIFT_VERSION = 5.0;
18491855
};
18501856
name = Release;
18511857
};

LayoutKitSampleApp/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
1818
window = UIWindow(frame: UIScreen.main.bounds)
1919
window?.rootViewController = UINavigationController(rootViewController: MenuViewController())
2020
window?.makeKeyAndVisible()

LayoutKitSampleApp/Benchmarks/TableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TableViewController<ContentViewType: UIView>: UITableViewController where
2828

2929
init(data: [CellType.DataType]) {
3030
self.data = data
31-
super.init(style: UITableViewStyle.grouped)
31+
super.init(style: UITableView.Style.grouped)
3232
}
3333

3434
required init?(coder aDecoder: NSCoder) {
@@ -52,7 +52,7 @@ class TableViewController<ContentViewType: UIView>: UITableViewController where
5252
}
5353

5454
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
55-
return UITableViewAutomaticDimension
55+
return UITableView.automaticDimension
5656
}
5757
}
5858

LayoutKitTests/LabelLayoutTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class LabelLayoutTests: XCTestCase {
5252
}
5353

5454
func testAttributedLabel() {
55-
let attributedText = NSAttributedString(string: "Hi", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)])
55+
let attributedText = NSAttributedString(string: "Hi", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)])
5656
let font = UIFont.helvetica(size: 99)
5757

5858
let arrangement = LabelLayout(attributedText: attributedText, font: font).arrangement()
@@ -122,7 +122,7 @@ class LabelLayoutTests: XCTestCase {
122122
func testAttributedTextCustomFont() {
123123
#if !os(tvOS) // tvOS doesn't currently support custom fonts
124124
let font = UIFont(name: "Papyrus", size: 20)!
125-
let attributes = [NSAttributedStringKey.font: font]
125+
let attributes = [NSAttributedString.Key.font: font]
126126
let text = NSAttributedString(string: "Hello! 😄😄😄", attributes: attributes)
127127

128128
let arrangement = LabelLayout(attributedText: text).arrangement()
@@ -136,7 +136,7 @@ class LabelLayoutTests: XCTestCase {
136136
#if !os(tvOS) // tvOS doesn't currently support custom fonts
137137
let font = UIFont(name: "Papyrus", size: 20)!
138138
let text = NSMutableAttributedString(string: "Hello world! 😄😄😄")
139-
text.addAttribute(NSAttributedStringKey.font, value: font, range: NSMakeRange(6, 6))
139+
text.addAttribute(NSAttributedString.Key.font, value: font, range: NSMakeRange(6, 6))
140140

141141
let arrangement = LabelLayout(attributedText: text).arrangement()
142142
let label = UILabel(attributedText: text)

LayoutKitTests/ReloadableViewLayoutAdapterCollectionViewTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ private class TestCollectionView: LayoutAdapterCollectionView, TestableReloadabl
110110
}
111111

112112
fileprivate func verifyHeader(_ section: Int, text: String?, frame: CGRect?, file: StaticString, line: UInt) {
113-
verifySupplementaryView(UICollectionElementKindSectionHeader, section: section, text: text, frame: frame, file: file, line: line)
113+
verifySupplementaryView(UICollectionView.elementKindSectionHeader, section: section, text: text, frame: frame, file: file, line: line)
114114
}
115115

116116
fileprivate func verifyFooter(_ section: Int, text: String?, frame: CGRect?, file: StaticString, line: UInt) {
117-
verifySupplementaryView(UICollectionElementKindSectionFooter, section: section, text: text, frame: frame, file: file, line: line)
117+
verifySupplementaryView(UICollectionView.elementKindSectionFooter, section: section, text: text, frame: frame, file: file, line: line)
118118
}
119119

120120
private func verifySupplementaryView(_ kind: String, section: Int, text: String?, frame: CGRect?, file: StaticString, line: UInt) {

LayoutKitTests/ReloadableViewLayoutAdapterTableViewTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ private class TestTableView: LayoutAdapterTableView, TestableReloadableView {
6868
reloadDataCount += 1
6969
}
7070

71-
fileprivate override func insertRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) {
71+
fileprivate override func insertRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) {
7272
super.insertRows(at: indexPaths, with: animation)
7373
batchUpdates.insertItems.append(contentsOf: indexPaths)
7474
}
7575

76-
fileprivate override func deleteRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) {
76+
fileprivate override func deleteRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) {
7777
super.deleteRows(at: indexPaths, with: animation)
7878
batchUpdates.deleteItems.append(contentsOf: indexPaths)
7979
}
8080

81-
fileprivate override func reloadRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) {
81+
fileprivate override func reloadRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) {
8282
super.reloadRows(at: indexPaths, with: animation)
8383
batchUpdates.reloadItems.append(contentsOf: indexPaths)
8484
}
@@ -88,17 +88,17 @@ private class TestTableView: LayoutAdapterTableView, TestableReloadableView {
8888
batchUpdates.moveItems.append(ItemMove(from: indexPath, to: newIndexPath))
8989
}
9090

91-
fileprivate override func insertSections(_ sections: IndexSet, with animation: UITableViewRowAnimation) {
91+
fileprivate override func insertSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) {
9292
super.insertSections(sections, with: animation)
9393
batchUpdates.insertSections.formUnion(sections)
9494
}
9595

96-
fileprivate override func reloadSections(_ sections: IndexSet, with animation: UITableViewRowAnimation) {
96+
fileprivate override func reloadSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) {
9797
super.reloadSections(sections, with: animation)
9898
batchUpdates.reloadSections.formUnion(sections)
9999
}
100100

101-
fileprivate override func deleteSections(_ sections: IndexSet, with animation: UITableViewRowAnimation) {
101+
fileprivate override func deleteSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) {
102102
super.deleteSections(sections, with: animation)
103103
batchUpdates.deleteSections.formUnion(sections)
104104
}

LayoutKitTests/TextExtension.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ extension Text {
3030
.unattributed("Hello! 😄😄😄"),
3131
.attributed(NSAttributedString(string: "")),
3232
.attributed(NSAttributedString(string: " ")),
33-
.attributed(NSAttributedString(string: "", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)])),
34-
.attributed(NSAttributedString(string: " ", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)])),
33+
.attributed(NSAttributedString(string: "", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)])),
34+
.attributed(NSAttributedString(string: " ", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)])),
3535
.attributed(NSAttributedString(string: "Hi")),
3636
.attributed(NSAttributedString(string: "Hello world")),
3737
.attributed(NSAttributedString(string: "Hello! 😄😄😄")),
38-
.attributed(NSAttributedString(string: "Hello! 😄😄😄", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)])),
38+
.attributed(NSAttributedString(string: "Hello! 😄😄😄", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)])),
3939
]
4040

4141
let fontSizes = 0...20

0 commit comments

Comments
 (0)