Skip to content

Commit 68e0e8d

Browse files
authored
Merge pull request #6 from layoutBox/migrate_to_swift_4
Migrate to swift 4
2 parents 76ef1a7 + 5318693 commit 68e0e8d

22 files changed

Lines changed: 186 additions & 64 deletions

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
gem 'synx'
3+
gem 'cocoapods'

Gemfile.lock

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (2.3.6)
5+
activesupport (4.2.10)
6+
i18n (~> 0.7)
7+
minitest (~> 5.1)
8+
thread_safe (~> 0.3, >= 0.3.4)
9+
tzinfo (~> 1.1)
10+
claide (1.0.2)
11+
clamp (0.6.5)
12+
cocoapods (1.3.1)
13+
activesupport (>= 4.0.2, < 5)
14+
claide (>= 1.0.2, < 2.0)
15+
cocoapods-core (= 1.3.1)
16+
cocoapods-deintegrate (>= 1.0.1, < 2.0)
17+
cocoapods-downloader (>= 1.1.3, < 2.0)
18+
cocoapods-plugins (>= 1.0.0, < 2.0)
19+
cocoapods-search (>= 1.0.0, < 2.0)
20+
cocoapods-stats (>= 1.0.0, < 2.0)
21+
cocoapods-trunk (>= 1.2.0, < 2.0)
22+
cocoapods-try (>= 1.1.0, < 2.0)
23+
colored2 (~> 3.1)
24+
escape (~> 0.0.4)
25+
fourflusher (~> 2.0.1)
26+
gh_inspector (~> 1.0)
27+
molinillo (~> 0.5.7)
28+
nap (~> 1.0)
29+
ruby-macho (~> 1.1)
30+
xcodeproj (>= 1.5.1, < 2.0)
31+
cocoapods-core (1.3.1)
32+
activesupport (>= 4.0.2, < 6)
33+
fuzzy_match (~> 2.0.4)
34+
nap (~> 1.0)
35+
cocoapods-deintegrate (1.0.1)
36+
cocoapods-downloader (1.1.3)
37+
cocoapods-plugins (1.0.0)
38+
nap
39+
cocoapods-search (1.0.0)
40+
cocoapods-stats (1.0.0)
41+
cocoapods-trunk (1.3.0)
42+
nap (>= 0.8, < 2.0)
43+
netrc (~> 0.11)
44+
cocoapods-try (1.1.0)
45+
colored2 (3.1.2)
46+
colorize (0.8.1)
47+
concurrent-ruby (1.0.5)
48+
escape (0.0.4)
49+
fourflusher (2.0.1)
50+
fuzzy_match (2.0.4)
51+
gh_inspector (1.0.3)
52+
i18n (0.9.1)
53+
concurrent-ruby (~> 1.0)
54+
minitest (5.11.1)
55+
molinillo (0.5.7)
56+
nanaimo (0.2.3)
57+
nap (1.1.0)
58+
netrc (0.11.0)
59+
ruby-macho (1.1.0)
60+
synx (0.2.1)
61+
clamp (~> 0.6)
62+
colorize (~> 0.7)
63+
xcodeproj (~> 1.0)
64+
thread_safe (0.3.6)
65+
tzinfo (1.2.4)
66+
thread_safe (~> 0.1)
67+
xcodeproj (1.5.4)
68+
CFPropertyList (~> 2.3.3)
69+
claide (>= 1.0.2, < 2.0)
70+
colored2 (~> 3.1)
71+
nanaimo (~> 0.2.3)
72+
73+
PLATFORMS
74+
ruby
75+
76+
DEPENDENCIES
77+
cocoapods
78+
synx
79+
80+
BUNDLED WITH
81+
1.13.1

LayoutFrameworkBenchmark.xcodeproj/project.pbxproj

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
isa = PBXGroup;
6767
children = (
6868
2401BCA21F4F045600788998 /* AutoLayout */,
69-
2401BC9F1F4F043800788998 /* UIStackView */,
70-
2401BC9C1F4F041400788998 /* ManualLayout */,
7169
2401BC921F4F020D00788998 /* FlexLayout */,
7270
2401BC8D1F4F01CC00788998 /* LayoutKit */,
71+
2401BC9C1F4F041400788998 /* ManualLayout */,
7372
2401BC911F4F020600788998 /* PinLayout */,
73+
2401BC9F1F4F043800788998 /* UIStackView */,
7474
2401BC751F4F018C00788998 /* BenchmarkViewController.swift */,
7575
2401BC761F4F018C00788998 /* CollectionViewController.swift */,
7676
2401BC771F4F018C00788998 /* DataBinder.swift */,
@@ -215,11 +215,12 @@
215215
isa = PBXProject;
216216
attributes = {
217217
LastSwiftUpdateCheck = 0830;
218-
LastUpgradeCheck = 0830;
218+
LastUpgradeCheck = 0920;
219219
TargetAttributes = {
220220
24661CFB1F4EFFF5002CB883 = {
221221
CreatedOnToolsVersion = 8.3.2;
222222
DevelopmentTeam = 4Q596JWQC5;
223+
LastSwiftMigration = 0920;
223224
ProvisioningStyle = Automatic;
224225
};
225226
};
@@ -280,18 +281,14 @@
280281
"${BUILT_PRODUCTS_DIR}/FlexLayout/FlexLayout.framework",
281282
"${BUILT_PRODUCTS_DIR}/LayoutKit/LayoutKit.framework",
282283
"${BUILT_PRODUCTS_DIR}/PinLayout/PinLayout.framework",
283-
"${PODS_ROOT}/Reveal-SDK/RevealServer-10/iOS/RevealServer.framework",
284-
"${BUILT_PRODUCTS_DIR}/Yoga/yoga.framework",
285-
"${BUILT_PRODUCTS_DIR}/YogaKit/YogaKit.framework",
284+
"${PODS_ROOT}/Reveal-SDK/RevealServer-13/iOS/RevealServer.framework",
286285
);
287286
name = "[CP] Embed Pods Frameworks";
288287
outputPaths = (
289288
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FlexLayout.framework",
290289
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LayoutKit.framework",
291290
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PinLayout.framework",
292291
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RevealServer.framework",
293-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/yoga.framework",
294-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YogaKit.framework",
295292
);
296293
runOnlyForDeploymentPostprocessing = 0;
297294
shellPath = /bin/sh;
@@ -313,7 +310,7 @@
313310
);
314311
runOnlyForDeploymentPostprocessing = 0;
315312
shellPath = /bin/sh;
316-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
313+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
317314
showEnvVarsInLog = 0;
318315
};
319316
/* End PBXShellScriptBuildPhase section */
@@ -364,15 +361,21 @@
364361
CLANG_CXX_LIBRARY = "libc++";
365362
CLANG_ENABLE_MODULES = YES;
366363
CLANG_ENABLE_OBJC_ARC = YES;
364+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
367365
CLANG_WARN_BOOL_CONVERSION = YES;
366+
CLANG_WARN_COMMA = YES;
368367
CLANG_WARN_CONSTANT_CONVERSION = YES;
369368
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
370369
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
371370
CLANG_WARN_EMPTY_BODY = YES;
372371
CLANG_WARN_ENUM_CONVERSION = YES;
373372
CLANG_WARN_INFINITE_RECURSION = YES;
374373
CLANG_WARN_INT_CONVERSION = YES;
374+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
375+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
375376
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
377+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
378+
CLANG_WARN_STRICT_PROTOTYPES = YES;
376379
CLANG_WARN_SUSPICIOUS_MOVE = YES;
377380
CLANG_WARN_UNREACHABLE_CODE = YES;
378381
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -395,7 +398,7 @@
395398
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
396399
GCC_WARN_UNUSED_FUNCTION = YES;
397400
GCC_WARN_UNUSED_VARIABLE = YES;
398-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
401+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
399402
MTL_ENABLE_DEBUG_INFO = YES;
400403
ONLY_ACTIVE_ARCH = YES;
401404
SDKROOT = iphoneos;
@@ -415,15 +418,21 @@
415418
CLANG_CXX_LIBRARY = "libc++";
416419
CLANG_ENABLE_MODULES = YES;
417420
CLANG_ENABLE_OBJC_ARC = YES;
421+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
418422
CLANG_WARN_BOOL_CONVERSION = YES;
423+
CLANG_WARN_COMMA = YES;
419424
CLANG_WARN_CONSTANT_CONVERSION = YES;
420425
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
421426
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
422427
CLANG_WARN_EMPTY_BODY = YES;
423428
CLANG_WARN_ENUM_CONVERSION = YES;
424429
CLANG_WARN_INFINITE_RECURSION = YES;
425430
CLANG_WARN_INT_CONVERSION = YES;
431+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
432+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
426433
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
434+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
435+
CLANG_WARN_STRICT_PROTOTYPES = YES;
427436
CLANG_WARN_SUSPICIOUS_MOVE = YES;
428437
CLANG_WARN_UNREACHABLE_CODE = YES;
429438
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -440,7 +449,7 @@
440449
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
441450
GCC_WARN_UNUSED_FUNCTION = YES;
442451
GCC_WARN_UNUSED_VARIABLE = YES;
443-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
452+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
444453
MTL_ENABLE_DEBUG_INFO = NO;
445454
SDKROOT = iphoneos;
446455
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -461,7 +470,8 @@
461470
PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.LayoutFrameworkBenchmark;
462471
PRODUCT_NAME = "$(TARGET_NAME)";
463472
PROVISIONING_PROFILE_SPECIFIER = "";
464-
SWIFT_VERSION = 3.0;
473+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
474+
SWIFT_VERSION = 4.0;
465475
};
466476
name = Debug;
467477
};
@@ -477,7 +487,8 @@
477487
PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.LayoutFrameworkBenchmark;
478488
PRODUCT_NAME = "$(TARGET_NAME)";
479489
PROVISIONING_PROFILE_SPECIFIER = "";
480-
SWIFT_VERSION = 3.0;
490+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
491+
SWIFT_VERSION = 4.0;
481492
};
482493
name = Release;
483494
};

LayoutFrameworkBenchmark.xcodeproj/xcshareddata/xcschemes/LayoutFrameworkBenchmark.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 = "0830"
3+
LastUpgradeVersion = "0920"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

LayoutFrameworkBenchmark/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
"idiom" : "ipad",
9090
"filename" : "Icon-167.png",
9191
"scale" : "2x"
92+
},
93+
{
94+
"idiom" : "ios-marketing",
95+
"size" : "1024x1024",
96+
"scale" : "1x"
9297
}
9398
],
9499
"info" : {

LayoutFrameworkBenchmark/Benchmarks/AutoLayout/FeedItemAutoLayoutView.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class CommentView: UIView {
6161
let actorImageView: UIImageView = {
6262
let i = UIImageView()
6363
i.image = UIImage(named: "50x50.png")
64-
i.setContentHuggingPriority(UILayoutPriorityRequired, for: .horizontal)
65-
i.setContentCompressionResistancePriority(UILayoutPriorityRequired, for: .horizontal)
64+
i.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
65+
i.setContentCompressionResistancePriority(UILayoutPriority.required, for: .horizontal)
6666
return i
6767
}()
6868

@@ -130,8 +130,8 @@ class MiniProfileView: UIView {
130130
i.image = UIImage(named: "50x50.png")
131131
i.backgroundColor = UIColor.orange
132132
i.contentMode = .center
133-
i.setContentHuggingPriority(UILayoutPriorityRequired, for: .horizontal)
134-
i.setContentCompressionResistancePriority(UILayoutPriorityRequired, for: .horizontal)
133+
i.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
134+
i.setContentCompressionResistancePriority(UILayoutPriority.required, for: .horizontal)
135135
return i
136136
}()
137137

@@ -228,8 +228,8 @@ class TopBarView: UIView {
228228
let optionsLabel: UILabel = {
229229
let l = UILabel()
230230
l.text = "..."
231-
l.setContentHuggingPriority(UILayoutPriorityRequired, for: .horizontal)
232-
l.setContentCompressionResistancePriority(UILayoutPriorityRequired, for: .horizontal)
231+
l.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
232+
l.setContentCompressionResistancePriority(UILayoutPriority.required, for: .horizontal)
233233
return l
234234
}()
235235

LayoutFrameworkBenchmark/Benchmarks/BenchmarkViewController.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class BenchmarkViewController: UITableViewController {
2424
return CollectionViewControllerFeedItemAutoLayoutView(data: data)
2525
}),
2626

27-
ViewControllerData(title: "FlexLayout", factoryBlock: { viewCount in
27+
ViewControllerData(title: "FlexLayout 1.3", factoryBlock: { viewCount in
2828
let data = FeedItemData.generate(count: viewCount)
2929
return CollectionViewControllerFeedItemFlexLayoutView(data: data)
3030
}),
3131

32-
ViewControllerData(title: "LayoutKit", factoryBlock: { viewCount in
32+
ViewControllerData(title: "LayoutKit 7.0", factoryBlock: { viewCount in
3333
let data = FeedItemData.generate(count: viewCount)
3434
return CollectionViewControllerFeedItemLayoutKitView(data: data)
3535
}),
@@ -39,7 +39,7 @@ class BenchmarkViewController: UITableViewController {
3939
return CollectionViewControllerFeedItemManualView(data: data)
4040
}),
4141

42-
ViewControllerData(title: "PinLayout", factoryBlock: { viewCount in
42+
ViewControllerData(title: "PinLayout 1.5", factoryBlock: { viewCount in
4343
let data = FeedItemData.generate(count: viewCount)
4444
return CollectionViewControllerFeedItemPinLayoutView(data: data)
4545
}),
@@ -101,7 +101,7 @@ class BenchmarkViewController: UITableViewController {
101101
func benchmarkCompleted(_ results: [Result]) {
102102
printResults(name: viewControllers[benchmarkIndex].title, results: results)
103103

104-
Timer.scheduledTimer(withTimeInterval: 0, repeats: false, block: { (_) in
104+
DispatchQueue.main.async {
105105
self.navigationController?.popViewController(animated: false)
106106

107107
benchmarkIndex += 1
@@ -110,7 +110,7 @@ class BenchmarkViewController: UITableViewController {
110110
} else {
111111
print("Completed!")
112112
}
113-
})
113+
}
114114
}
115115

116116
runBenchmark(viewControllerData: viewControllers[benchmarkIndex], logResults: false, completed: benchmarkCompleted)
@@ -136,9 +136,10 @@ class BenchmarkViewController: UITableViewController {
136136
}
137137

138138
private func benchmark(_ viewControllerData: ViewControllerData, logResults: Bool, completed: ((_ results: [Result]) -> Void)?) {
139+
// let iterations = [1]
139140
let iterations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
140141
var results: [Result] = []
141-
142+
142143
for i in iterations {
143144
let description = "\(i)\tsubviews\t\(viewControllerData.title)"
144145
let result = Stopwatch.benchmark(description, logResults: logResults, block: { (stopwatch: Stopwatch) -> Void in

LayoutFrameworkBenchmark/Benchmarks/FlexLayout/FeedItemFlexLayoutView.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77

88
import UIKit
9-
import PinLayout
109
import FlexLayout
1110

12-
/// A LinkedIn feed item that is implemented with PinLayout code.
11+
/// A LinkedIn feed item that is implemented with FlexLayout code.
1312
class FeedItemFlexLayoutView: UIView, DataBinder {
1413

1514
let contentView = UIView()
@@ -172,15 +171,15 @@ class FeedItemFlexLayoutView: UIView, DataBinder {
172171
override func layoutSubviews() {
173172
super.layoutSubviews()
174173

175-
layoutFlexbox(size: bounds.size)
174+
layout(size: bounds.size)
176175
}
177176

178-
fileprivate func layoutFlexbox(size: CGSize) {
177+
fileprivate func layout(size: CGSize) {
179178
flex.size(size).layout()
180179
}
181180

182181
override func sizeThatFits(_ size: CGSize) -> CGSize {
183-
layoutFlexbox(size: CGSize(width: size.width != .greatestFiniteMagnitude ? size.width : 10000,
182+
layout(size: CGSize(width: size.width != .greatestFiniteMagnitude ? size.width : 10000,
184183
height: size.height != .greatestFiniteMagnitude ? size.height : 10000))
185184
return CGSize(width: size.width, height: contentView.frame.height + 4)
186185
}

LayoutFrameworkBenchmark/Benchmarks/PinLayout/FeedItemPinLayoutView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class FeedItemPinLayoutView: UIView, DataBinder {
163163
contentDomainLabel.pin.below(of: contentTitleLabel, aligned: .left).right().marginRight(hMargin).sizeToFit(.width)
164164

165165
likeLabel.pin.below(of: contentDomainLabel, aligned: .left).marginTop(vMargin)
166-
commentLabel.pin.top(to: likeLabel.edge.top).hCenter(50%)
166+
commentLabel.pin.top(to: likeLabel.edge.top).hCenter()
167167
shareLabel.pin.top(to: likeLabel.edge.top).right().marginRight(hMargin)
168168

169169
actorImageView.pin.below(of: likeLabel, aligned: .left).marginTop(vMargin)

0 commit comments

Comments
 (0)