Skip to content

Commit

Permalink
Merge pull request #96 from hyperoslo/swift4
Browse files Browse the repository at this point in the history
Migrate the project to Swift4
  • Loading branch information
vadymmarkov authored Oct 2, 2017
2 parents 0eb67fe + 37521ed commit d7793c9
Show file tree
Hide file tree
Showing 27 changed files with 323 additions and 278 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
osx_image: xcode8
osx_image: xcode9
language: objective-c
xcode_sdk: iphonesimulator10.0

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

script:
- xcodebuild clean build -project Presentation.xcodeproj -scheme "Presentation-iOS" -sdk iphonesimulator
- set -o pipefail
- travis_retry xcodebuild clean build -project Presentation.xcodeproj -scheme "Presentation-iOS" -destination "platform=iOS Simulator,name=iPhone 6" | xcpretty
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "hyperoslo/Pages"
github "robb/Cartography"
github "hyperoslo/Pages"
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "robb/Cartography" "1.0.1"
github "hyperoslo/Pages" "1.0.0"
github "hyperoslo/Pages" "2.0.2"
github "robb/Cartography" "2.0.0"
1 change: 1 addition & 0 deletions Example/Parallax/.swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0
36 changes: 31 additions & 5 deletions Example/Parallax/Parallax.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Hyper;
TargetAttributes = {
D563C9F51AF6DD6400E2F7C8 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -179,13 +179,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Parallax-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
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";
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";
showEnvVarsInLog = 0;
};
513D09C629696FF9539C0C6E /* [CP] Copy Pods Resources */ = {
Expand All @@ -209,9 +212,18 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Parallax/Pods-Parallax-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Cartography/Cartography.framework",
"${BUILT_PRODUCTS_DIR}/Hue/Hue.framework",
"${BUILT_PRODUCTS_DIR}/Pages/Pages.framework",
"${BUILT_PRODUCTS_DIR}/Presentation/Presentation.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cartography.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Pages.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Presentation.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -252,14 +264,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -301,14 +319,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -345,7 +369,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -360,7 +385,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
20 changes: 6 additions & 14 deletions Example/Parallax/Parallax/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

lazy var navigationController: UINavigationController = { [unowned self] in
let controller = UINavigationController(rootViewController: self.presentationController)

return controller
}()

lazy var presentationController: ViewController = {
return ViewController(pages: [])
}()

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
private lazy var navigationController: UINavigationController = .init(
rootViewController: self.presentationController
)
private lazy var presentationController: ViewController = .init(pages: [])

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
UINavigationBar.appearance().barStyle = .default
UINavigationBar.appearance().shadowImage = UIImage()
Expand Down
52 changes: 29 additions & 23 deletions Example/Parallax/Parallax/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import Hue
import Presentation

class ViewController: PresentationController {

struct BackgroundImage {
private struct BackgroundImage {
let name: String
let left: CGFloat
let top: CGFloat
Expand All @@ -29,41 +28,43 @@ class ViewController: PresentationController {
}
}

lazy var leftButton: UIBarButtonItem = { [unowned self] in
private lazy var leftButton: UIBarButtonItem = { [unowned self] in
let leftButton = UIBarButtonItem(
title: "Previous",
style: .plain,
target: self,
action: #selector(moveBack))

leftButton.setTitleTextAttributes(
[NSForegroundColorAttributeName : UIColor.black],
for: .normal)
[NSAttributedStringKey.foregroundColor : UIColor.black],
for: .normal
)

return leftButton
}()
}()

lazy var rightButton: UIBarButtonItem = { [unowned self] in
private lazy var rightButton: UIBarButtonItem = { [unowned self] in
let rightButton = UIBarButtonItem(
title: "Next",
style: .plain,
target: self,
action: #selector(moveForward))
action: #selector(moveForward)
)

rightButton.setTitleTextAttributes(
[NSForegroundColorAttributeName : UIColor.black],
for: .normal)
[NSAttributedStringKey.foregroundColor : UIColor.black],
for: .normal
)

return rightButton
}()
}()

override func viewDidLoad() {
super.viewDidLoad()

setNavigationTitle = false
navigationItem.leftBarButtonItem = leftButton
navigationItem.rightBarButtonItem = rightButton

view.backgroundColor = UIColor(hex: "FFBC00")

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

// MARK: - Configuration

func configureSlides() {
private func configureSlides() {
let ratio: CGFloat = UIDevice.current.userInterfaceIdiom == .pad ? 1 : 0.6
let font = UIFont(name: "HelveticaNeue", size: 34.0 * ratio)!
let color = UIColor(hex: "FFE8A9")
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.center

let attributes = [NSFontAttributeName: font, NSForegroundColorAttributeName: color,
NSParagraphStyleAttributeName: paragraphStyle]
let attributes = [
NSAttributedStringKey.font: font,
NSAttributedStringKey.foregroundColor: color,
NSAttributedStringKey.paragraphStyle: paragraphStyle
]

let titles = [
"Parallax is a displacement or difference in the apparent position of an object viewed along two different lines of sight.",
Expand All @@ -101,14 +105,13 @@ class ViewController: PresentationController {
for index in 0...4 {
let controller = SlideController(contents: [titles[index]])
controller.add(animations: [Content.centerTransition(forSlideContent: titles[index])])

slides.append(controller)
}

add(slides)
}

func configureBackground() {
private func configureBackground() {
let backgroundImages = [
BackgroundImage(name: "Trees", left: 0.0, top: 0.743, speed: -0.3),
BackgroundImage(name: "Bus", left: 0.02, top: 0.77, speed: 0.25),
Expand Down Expand Up @@ -136,23 +139,26 @@ class ViewController: PresentationController {
for (column, backgroundImage) in backgroundImages.enumerated() {
if let position = backgroundImage.positionAt(row), let content = contents.at(column) {
addAnimation(TransitionAnimation(content: content, destination: position,
duration: 2.0, damping: 1.0), forPage: row)
duration: 2.0, damping: 1.0), forPage: row)
}
}
}

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

let groundContent = Content(
view: groundView,
position: Position(left: 0.0, bottom: 0.063),
centered: false
)

contents.append(groundContent)
addToBackground([groundContent])
}
}

extension Array {

private extension Array {
func at(_ index: Int?) -> Element? {
var object: Element?
if let index = index , index >= 0 && index < endIndex {
Expand Down
8 changes: 4 additions & 4 deletions Example/Parallax/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use_frameworks!

platform :ios, '8.0'

target 'Parallax' do
pod 'Presentation', path: '../../'
pod 'Hue', git: 'https://github.com/hyperoslo/Hue', branch: 'swift3'
end
pod 'Presentation', path: '../../'
pod 'Hue'

target 'Parallax'
32 changes: 12 additions & 20 deletions Example/Parallax/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
PODS:
- Cartography (1.0.1)
- Hue (1.2.0)
- Pages (1.0.0)
- Presentation (3.0.0):
- Cartography (2.0.0)
- Hue (2.0.1)
- Pages (2.0.2)
- Presentation (3.1.0):
- Cartography
- Pages

DEPENDENCIES:
- Hue (from `https://github.com/hyperoslo/Hue`, branch `swift3`)
- Hue
- Presentation (from `../../`)

EXTERNAL SOURCES:
Hue:
:branch: swift3
:git: https://github.com/hyperoslo/Hue
Presentation:
:path: "../../"

CHECKOUT OPTIONS:
Hue:
:commit: 3303cbcdf0f771aea1a6d1a153e4b95eef8696eb
:git: https://github.com/hyperoslo/Hue
:path: ../../

SPEC CHECKSUMS:
Cartography: c1460e99395b824d9d75360b0382faeb0b33dcd7
Hue: 0705083b7aff40334033373e6293ec1215285ac2
Pages: f3718e6f03a5e2787f6b0bff4becb3c7c19bcebc
Presentation: 2a7e0379ab403c0bd91c4f6d5c59480edba6f429
Cartography: d295eb25ab54bb57eecd8c2f04e9648c850f1281
Hue: 354caec055fdc9d38b5ef33ca2e7224721843baf
Pages: 5564ac6035c48fef7a837049314f57507d263b11
Presentation: 07f001419368d0ece73285f238b1dc3852462f23

PODFILE CHECKSUM: f41db61a2828ca5a77fd53546b00649e4bd644cc
PODFILE CHECKSUM: 8a38e1ff9630071a018856bbaebe49be27870e49

COCOAPODS: 1.2.0
COCOAPODS: 1.3.1
1 change: 1 addition & 0 deletions Example/Tutorial/.swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0
8 changes: 4 additions & 4 deletions Example/Tutorial/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use_frameworks!

platform :ios, '8.0'

target 'Tutorial' do
pod 'Presentation', path: '../../'
pod 'Hue', git: 'https://github.com/hyperoslo/Hue', branch: 'swift3'
end
pod 'Presentation', path: '../../'
pod 'Hue'

target 'Tutorial'
Loading

0 comments on commit d7793c9

Please sign in to comment.