Skip to content

Commit d7793c9

Browse files
authored
Merge pull request #96 from hyperoslo/swift4
Migrate the project to Swift4
2 parents 0eb67fe + 37521ed commit d7793c9

27 files changed

+323
-278
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
osx_image: xcode8
1+
osx_image: xcode9
22
language: objective-c
3+
xcode_sdk: iphonesimulator10.0
34

45
before_install:
56
- brew update
67
- if brew outdated | grep -qx carthage; then brew upgrade carthage; fi
78
- travis_wait 35 carthage bootstrap --platform iOS
89

910
script:
10-
- xcodebuild clean build -project Presentation.xcodeproj -scheme "Presentation-iOS" -sdk iphonesimulator
11+
- set -o pipefail
12+
- travis_retry xcodebuild clean build -project Presentation.xcodeproj -scheme "Presentation-iOS" -destination "platform=iOS Simulator,name=iPhone 6" | xcpretty

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "hyperoslo/Pages"
21
github "robb/Cartography"
2+
github "hyperoslo/Pages"

Cartfile.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "robb/Cartography" "1.0.1"
2-
github "hyperoslo/Pages" "1.0.0"
1+
github "hyperoslo/Pages" "2.0.2"
2+
github "robb/Cartography" "2.0.0"

Example/Parallax/.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0

Example/Parallax/Parallax.xcodeproj/project.pbxproj

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@
133133
isa = PBXProject;
134134
attributes = {
135135
LastSwiftUpdateCheck = 0700;
136-
LastUpgradeCheck = 0800;
136+
LastUpgradeCheck = 0900;
137137
ORGANIZATIONNAME = Hyper;
138138
TargetAttributes = {
139139
D563C9F51AF6DD6400E2F7C8 = {
140140
CreatedOnToolsVersion = 6.3.1;
141-
LastSwiftMigration = 0800;
141+
LastSwiftMigration = 0900;
142142
};
143143
};
144144
};
@@ -179,13 +179,16 @@
179179
files = (
180180
);
181181
inputPaths = (
182+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
183+
"${PODS_ROOT}/Manifest.lock",
182184
);
183185
name = "[CP] Check Pods Manifest.lock";
184186
outputPaths = (
187+
"$(DERIVED_FILE_DIR)/Pods-Parallax-checkManifestLockResult.txt",
185188
);
186189
runOnlyForDeploymentPostprocessing = 0;
187190
shellPath = /bin/sh;
188-
shellScript = "diff \"${PODS_ROOT}/../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";
191+
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";
189192
showEnvVarsInLog = 0;
190193
};
191194
513D09C629696FF9539C0C6E /* [CP] Copy Pods Resources */ = {
@@ -209,9 +212,18 @@
209212
files = (
210213
);
211214
inputPaths = (
215+
"${SRCROOT}/Pods/Target Support Files/Pods-Parallax/Pods-Parallax-frameworks.sh",
216+
"${BUILT_PRODUCTS_DIR}/Cartography/Cartography.framework",
217+
"${BUILT_PRODUCTS_DIR}/Hue/Hue.framework",
218+
"${BUILT_PRODUCTS_DIR}/Pages/Pages.framework",
219+
"${BUILT_PRODUCTS_DIR}/Presentation/Presentation.framework",
212220
);
213221
name = "[CP] Embed Pods Frameworks";
214222
outputPaths = (
223+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cartography.framework",
224+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework",
225+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Pages.framework",
226+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Presentation.framework",
215227
);
216228
runOnlyForDeploymentPostprocessing = 0;
217229
shellPath = /bin/sh;
@@ -252,14 +264,20 @@
252264
CLANG_CXX_LIBRARY = "libc++";
253265
CLANG_ENABLE_MODULES = YES;
254266
CLANG_ENABLE_OBJC_ARC = YES;
267+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
255268
CLANG_WARN_BOOL_CONVERSION = YES;
269+
CLANG_WARN_COMMA = YES;
256270
CLANG_WARN_CONSTANT_CONVERSION = YES;
257271
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
258272
CLANG_WARN_EMPTY_BODY = YES;
259273
CLANG_WARN_ENUM_CONVERSION = YES;
260274
CLANG_WARN_INFINITE_RECURSION = YES;
261275
CLANG_WARN_INT_CONVERSION = YES;
276+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
277+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
262278
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
279+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
280+
CLANG_WARN_STRICT_PROTOTYPES = YES;
263281
CLANG_WARN_SUSPICIOUS_MOVE = YES;
264282
CLANG_WARN_UNREACHABLE_CODE = YES;
265283
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -301,14 +319,20 @@
301319
CLANG_CXX_LIBRARY = "libc++";
302320
CLANG_ENABLE_MODULES = YES;
303321
CLANG_ENABLE_OBJC_ARC = YES;
322+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
304323
CLANG_WARN_BOOL_CONVERSION = YES;
324+
CLANG_WARN_COMMA = YES;
305325
CLANG_WARN_CONSTANT_CONVERSION = YES;
306326
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
307327
CLANG_WARN_EMPTY_BODY = YES;
308328
CLANG_WARN_ENUM_CONVERSION = YES;
309329
CLANG_WARN_INFINITE_RECURSION = YES;
310330
CLANG_WARN_INT_CONVERSION = YES;
331+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
332+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
311333
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
334+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
335+
CLANG_WARN_STRICT_PROTOTYPES = YES;
312336
CLANG_WARN_SUSPICIOUS_MOVE = YES;
313337
CLANG_WARN_UNREACHABLE_CODE = YES;
314338
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -345,7 +369,8 @@
345369
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
346370
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
347371
PRODUCT_NAME = "$(TARGET_NAME)";
348-
SWIFT_VERSION = 3.0;
372+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
373+
SWIFT_VERSION = 4.0;
349374
TARGETED_DEVICE_FAMILY = "1,2";
350375
};
351376
name = Debug;
@@ -360,7 +385,8 @@
360385
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
361386
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
362387
PRODUCT_NAME = "$(TARGET_NAME)";
363-
SWIFT_VERSION = 3.0;
388+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
389+
SWIFT_VERSION = 4.0;
364390
TARGETED_DEVICE_FAMILY = "1,2";
365391
};
366392
name = Release;

Example/Parallax/Parallax/AppDelegate.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@ import UIKit
22

33
@UIApplicationMain
44
class AppDelegate: UIResponder, UIApplicationDelegate {
5-
65
var window: UIWindow?
76

8-
lazy var navigationController: UINavigationController = { [unowned self] in
9-
let controller = UINavigationController(rootViewController: self.presentationController)
10-
11-
return controller
12-
}()
13-
14-
lazy var presentationController: ViewController = {
15-
return ViewController(pages: [])
16-
}()
17-
18-
func application(
19-
_ application: UIApplication,
20-
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
7+
private lazy var navigationController: UINavigationController = .init(
8+
rootViewController: self.presentationController
9+
)
10+
private lazy var presentationController: ViewController = .init(pages: [])
2111

12+
func application(_ application: UIApplication,
13+
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2214
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
2315
UINavigationBar.appearance().barStyle = .default
2416
UINavigationBar.appearance().shadowImage = UIImage()

Example/Parallax/Parallax/ViewController.swift

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import Hue
33
import Presentation
44

55
class ViewController: PresentationController {
6-
7-
struct BackgroundImage {
6+
private struct BackgroundImage {
87
let name: String
98
let left: CGFloat
109
let top: CGFloat
@@ -29,41 +28,43 @@ class ViewController: PresentationController {
2928
}
3029
}
3130

32-
lazy var leftButton: UIBarButtonItem = { [unowned self] in
31+
private lazy var leftButton: UIBarButtonItem = { [unowned self] in
3332
let leftButton = UIBarButtonItem(
3433
title: "Previous",
3534
style: .plain,
3635
target: self,
3736
action: #selector(moveBack))
3837

3938
leftButton.setTitleTextAttributes(
40-
[NSForegroundColorAttributeName : UIColor.black],
41-
for: .normal)
39+
[NSAttributedStringKey.foregroundColor : UIColor.black],
40+
for: .normal
41+
)
4242

4343
return leftButton
44-
}()
44+
}()
4545

46-
lazy var rightButton: UIBarButtonItem = { [unowned self] in
46+
private lazy var rightButton: UIBarButtonItem = { [unowned self] in
4747
let rightButton = UIBarButtonItem(
4848
title: "Next",
4949
style: .plain,
5050
target: self,
51-
action: #selector(moveForward))
51+
action: #selector(moveForward)
52+
)
5253

5354
rightButton.setTitleTextAttributes(
54-
[NSForegroundColorAttributeName : UIColor.black],
55-
for: .normal)
55+
[NSAttributedStringKey.foregroundColor : UIColor.black],
56+
for: .normal
57+
)
5658

5759
return rightButton
58-
}()
60+
}()
5961

6062
override func viewDidLoad() {
6163
super.viewDidLoad()
6264

6365
setNavigationTitle = false
6466
navigationItem.leftBarButtonItem = leftButton
6567
navigationItem.rightBarButtonItem = rightButton
66-
6768
view.backgroundColor = UIColor(hex: "FFBC00")
6869

6970
configureSlides()
@@ -72,15 +73,18 @@ class ViewController: PresentationController {
7273

7374
// MARK: - Configuration
7475

75-
func configureSlides() {
76+
private func configureSlides() {
7677
let ratio: CGFloat = UIDevice.current.userInterfaceIdiom == .pad ? 1 : 0.6
7778
let font = UIFont(name: "HelveticaNeue", size: 34.0 * ratio)!
7879
let color = UIColor(hex: "FFE8A9")
7980
let paragraphStyle = NSMutableParagraphStyle()
8081
paragraphStyle.alignment = NSTextAlignment.center
8182

82-
let attributes = [NSFontAttributeName: font, NSForegroundColorAttributeName: color,
83-
NSParagraphStyleAttributeName: paragraphStyle]
83+
let attributes = [
84+
NSAttributedStringKey.font: font,
85+
NSAttributedStringKey.foregroundColor: color,
86+
NSAttributedStringKey.paragraphStyle: paragraphStyle
87+
]
8488

8589
let titles = [
8690
"Parallax is a displacement or difference in the apparent position of an object viewed along two different lines of sight.",
@@ -101,14 +105,13 @@ class ViewController: PresentationController {
101105
for index in 0...4 {
102106
let controller = SlideController(contents: [titles[index]])
103107
controller.add(animations: [Content.centerTransition(forSlideContent: titles[index])])
104-
105108
slides.append(controller)
106109
}
107110

108111
add(slides)
109112
}
110113

111-
func configureBackground() {
114+
private func configureBackground() {
112115
let backgroundImages = [
113116
BackgroundImage(name: "Trees", left: 0.0, top: 0.743, speed: -0.3),
114117
BackgroundImage(name: "Bus", left: 0.02, top: 0.77, speed: 0.25),
@@ -136,23 +139,26 @@ class ViewController: PresentationController {
136139
for (column, backgroundImage) in backgroundImages.enumerated() {
137140
if let position = backgroundImage.positionAt(row), let content = contents.at(column) {
138141
addAnimation(TransitionAnimation(content: content, destination: position,
139-
duration: 2.0, damping: 1.0), forPage: row)
142+
duration: 2.0, damping: 1.0), forPage: row)
140143
}
141144
}
142145
}
143146

144147
let groundView = UIView(frame: CGRect(x: 0, y: 0, width: 1024, height: 60))
145148
groundView.backgroundColor = UIColor(hex: "FFCD41")
146-
let groundContent = Content(view: groundView,
147-
position: Position(left: 0.0, bottom: 0.063), centered: false)
148-
contents.append(groundContent)
149149

150+
let groundContent = Content(
151+
view: groundView,
152+
position: Position(left: 0.0, bottom: 0.063),
153+
centered: false
154+
)
155+
156+
contents.append(groundContent)
150157
addToBackground([groundContent])
151158
}
152159
}
153160

154-
extension Array {
155-
161+
private extension Array {
156162
func at(_ index: Int?) -> Element? {
157163
var object: Element?
158164
if let index = index , index >= 0 && index < endIndex {

Example/Parallax/Podfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use_frameworks!
22

33
platform :ios, '8.0'
44

5-
target 'Parallax' do
6-
pod 'Presentation', path: '../../'
7-
pod 'Hue', git: 'https://github.com/hyperoslo/Hue', branch: 'swift3'
8-
end
5+
pod 'Presentation', path: '../../'
6+
pod 'Hue'
7+
8+
target 'Parallax'

Example/Parallax/Podfile.lock

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
11
PODS:
2-
- Cartography (1.0.1)
3-
- Hue (1.2.0)
4-
- Pages (1.0.0)
5-
- Presentation (3.0.0):
2+
- Cartography (2.0.0)
3+
- Hue (2.0.1)
4+
- Pages (2.0.2)
5+
- Presentation (3.1.0):
66
- Cartography
77
- Pages
88

99
DEPENDENCIES:
10-
- Hue (from `https://github.com/hyperoslo/Hue`, branch `swift3`)
10+
- Hue
1111
- Presentation (from `../../`)
1212

1313
EXTERNAL SOURCES:
14-
Hue:
15-
:branch: swift3
16-
:git: https://github.com/hyperoslo/Hue
1714
Presentation:
18-
:path: "../../"
19-
20-
CHECKOUT OPTIONS:
21-
Hue:
22-
:commit: 3303cbcdf0f771aea1a6d1a153e4b95eef8696eb
23-
:git: https://github.com/hyperoslo/Hue
15+
:path: ../../
2416

2517
SPEC CHECKSUMS:
26-
Cartography: c1460e99395b824d9d75360b0382faeb0b33dcd7
27-
Hue: 0705083b7aff40334033373e6293ec1215285ac2
28-
Pages: f3718e6f03a5e2787f6b0bff4becb3c7c19bcebc
29-
Presentation: 2a7e0379ab403c0bd91c4f6d5c59480edba6f429
18+
Cartography: d295eb25ab54bb57eecd8c2f04e9648c850f1281
19+
Hue: 354caec055fdc9d38b5ef33ca2e7224721843baf
20+
Pages: 5564ac6035c48fef7a837049314f57507d263b11
21+
Presentation: 07f001419368d0ece73285f238b1dc3852462f23
3022

31-
PODFILE CHECKSUM: f41db61a2828ca5a77fd53546b00649e4bd644cc
23+
PODFILE CHECKSUM: 8a38e1ff9630071a018856bbaebe49be27870e49
3224

33-
COCOAPODS: 1.2.0
25+
COCOAPODS: 1.3.1

Example/Tutorial/.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0

Example/Tutorial/Podfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use_frameworks!
44

55
platform :ios, '8.0'
66

7-
target 'Tutorial' do
8-
pod 'Presentation', path: '../../'
9-
pod 'Hue', git: 'https://github.com/hyperoslo/Hue', branch: 'swift3'
10-
end
7+
pod 'Presentation', path: '../../'
8+
pod 'Hue'
9+
10+
target 'Tutorial'

0 commit comments

Comments
 (0)