Skip to content

Commit

Permalink
XCode 10 and swift 4.2 fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sinarionn committed Oct 11, 2018
1 parent 70f6f4c commit 2c57b3e
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 41 deletions.
4 changes: 2 additions & 2 deletions AppRouter.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "AppRouter"
s.version = "5.0.0"
s.version = "5.1.0"
s.summary = "UIViewController creation, navigation, utility methods for easy routing"

s.homepage = "https://github.com/MLSDev/AppRouter"
Expand Down Expand Up @@ -30,7 +30,7 @@ Pod::Spec.new do |s|

route.subspec 'Dip' do |dip|
dip.source_files = 'Sources/Route/*.swift'
dip.dependency 'Dip', '~> 6.0'
dip.dependency 'Dip', '~> 7.0'
dip.ios.deployment_target = "9.0"
end
end
Expand Down
21 changes: 15 additions & 6 deletions AppRouter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -527,24 +527,27 @@
TargetAttributes = {
C0388C6E2109CA3F00E42364 = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
};
C089D31D1D54A3BF00599DD7 = {
CreatedOnToolsVersion = 7.3;
DevelopmentTeam = L94VC9ZZXC;
LastSwiftMigration = 0800;
LastSwiftMigration = 1000;
};
C089D3261D54A3BF00599DD7 = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0940;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
TestTargetID = C0388C6E2109CA3F00E42364;
};
C0BD354C2102507A00513C86 = {
DevelopmentTeam = L94VC9ZZXC;
LastSwiftMigration = 1000;
};
C0D64FC11FB44E25003B6B89 = {
DevelopmentTeam = L94VC9ZZXC;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -897,7 +900,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -925,7 +928,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -950,6 +953,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
VERSION_INFO_PREFIX = "";
};
name = Debug;
Expand All @@ -974,6 +978,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
VERSION_INFO_PREFIX = "";
};
name = Release;
Expand All @@ -996,6 +1001,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestApp.app/TestApp";
};
name = Debug;
Expand All @@ -1019,6 +1025,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestApp.app/TestApp";
};
name = Release;
Expand All @@ -1043,6 +1050,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1066,6 +1074,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1087,9 +1096,9 @@
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = mlsdev.AppRouter.rx;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx";
SWIFT_VERSION = 4.2;
VERSION_INFO_PREFIX = "";
};
name = Debug;
Expand All @@ -1112,9 +1121,9 @@
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = mlsdev.AppRouter.rx;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx";
SWIFT_VERSION = 4.2;
VERSION_INFO_PREFIX = "";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [5.1.0](https://github.com/MLSDev/AppRouter/releases/tag/5.1.0)

XCode 10 and swift 4.2 fixes.


## [5.0.0](https://github.com/MLSDev/AppRouter/releases/tag/5.0.0)

New 'AppRouter/Route' subspec.
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "ReactiveX/RxSwift"
github "sinarionn/ReusableView"
github "AliSoftware/Dip"
github "AliSoftware/Dip" "swift42"
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "AliSoftware/Dip" "6.1"
github "ReactiveX/RxSwift" "4.2.0"
github "sinarionn/ReusableView" "2.0.1"
github "AliSoftware/Dip" "dadb68862a4a8ad6228f3584e0ec19ded0f95098"
github "ReactiveX/RxSwift" "4.3.0"
github "sinarionn/ReusableView" "2.0.2"
2 changes: 1 addition & 1 deletion Plists/AppRouter.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Plists/AppRouterRoute.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
![AppRouter Logo](/logo.png)


![Build Status](https://travis-ci.org/MLSDev/AppRouter.svg?branch=master) &nbsp;
[![codecov.io](http://codecov.io/github/MLSDev/AppRouter/coverage.svg?branch=master)](http://codecov.io/github/MLSDev/AppRouter?branch=master)
![CocoaPod platform](https://cocoapod-badges.herokuapp.com/p/AppRouter/badge.png) &nbsp;
Expand Down
12 changes: 6 additions & 6 deletions Sources/Core/AppRouter+animations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension AppRouter {
public struct RootAnimator {
let router: AppRouterType

public func setRoot(controller: UIViewController, animation: AnimationType, callback: Func<Bool, Void>? = nil) {
public func setRoot(controller: UIViewController, animation: AnimationType, callback: ((Bool)->())? = nil) {
switch animation {
case .none:
router.rootViewController = controller
Expand All @@ -32,7 +32,7 @@ extension AppRouter {
/// - parameter options: animation options used to animate transition.
/// - parameter duration: animation duration
/// - parameter callback: called after controller becomes rootViewController
public func setRootWithViewAnimation(_ controller: UIViewController, options: UIViewAnimationOptions = .transitionFlipFromLeft, duration: TimeInterval = 0.3, callback: Func<Bool, Void>? = nil) {
public func setRootWithViewAnimation(_ controller: UIViewController, options: UIView.AnimationOptions = .transitionFlipFromLeft, duration: TimeInterval = 0.3, callback: ((Bool)->())? = nil) {
if let rootController = router.rootViewController {
let oldState = UIView.areAnimationsEnabled
UIView.setAnimationsEnabled(false)
Expand All @@ -53,7 +53,7 @@ extension AppRouter {
/// - parameter options: animation options used to animate transition.
/// - parameter duration: animation duration
/// - parameter callback: called after controller becomes rootViewController
public func setRootWithWindowAnimation(_ controller: UIViewController, options: UIViewAnimationOptions = .transitionFlipFromLeft, duration: TimeInterval = 0.3, callback: Func<Bool, Void>? = nil) {
public func setRootWithWindowAnimation(_ controller: UIViewController, options: UIView.AnimationOptions = .transitionFlipFromLeft, duration: TimeInterval = 0.3, callback: ((Bool)->())? = nil) {
if let _ = router.rootViewController {
let oldState = UIView.areAnimationsEnabled
UIView.setAnimationsEnabled(false)
Expand All @@ -76,7 +76,7 @@ extension AppRouter {
/// - parameter opacityTo: final snapshot opacity
/// - parameter duration: animation duration
/// - parameter callback: called after controller becomes rootViewController
public func setRootWithSnapshotAnimation(_ controller: UIViewController, upscaleTo: CGFloat = 1.2, opacityTo: Float = 0, duration: TimeInterval = 0.3, callback: Func<Bool, Void>? = nil) {
public func setRootWithSnapshotAnimation(_ controller: UIViewController, upscaleTo: CGFloat = 1.2, opacityTo: Float = 0, duration: TimeInterval = 0.3, callback: ((Bool)->())? = nil) {
if let _ = router.rootViewController, let snapshot:UIView = router.window.snapshotView(afterScreenUpdates: true) {
controller.view.addSubview(snapshot)
router.rootViewController = controller
Expand All @@ -96,8 +96,8 @@ extension AppRouter {

public enum AnimationType {
case none
case view(options: UIViewAnimationOptions, duration: TimeInterval)
case window(options: UIViewAnimationOptions, duration: TimeInterval)
case view(options: UIView.AnimationOptions, duration: TimeInterval)
case window(options: UIView.AnimationOptions, duration: TimeInterval)
case snapshotUpscale(scaleTo: CGFloat, opacityTo: Float, duration: TimeInterval)
}
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/Core/AppRouter+instantiations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ extension UIStoryboard {
}
if let navigation = controller as? UINavigationController {
let first = navigation.viewControllers.first as? T
#if swift(>=4.2)
first?.removeFromParent()
#else
first?.removeFromParentViewController()
#endif

return first
}
return nil
Expand Down
26 changes: 13 additions & 13 deletions Sources/Core/AppRouter+navigations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extension AppRouter {
///
/// - parameter animated: defines if popping should be animated
/// - parameter completion: called after successful popping
public class func popFromTopNavigation(animated: Bool = true, completion: Func<Void, Void>? = nil) {
public class func popFromTopNavigation(animated: Bool = true, completion: (()->())? = nil) {
_ = topViewController()?.navigationController?.popViewController(animated: animated, completion: completion)
}
}
Expand All @@ -19,7 +19,7 @@ extension UIViewController {
/// - parameter completion: Called after transition ends successfully.
/// - returns: [UIViewCotnroller]? - returns the popped controllers
@discardableResult
public func pop(animated: Bool = true, completion: Func<Void, Void>? = nil) -> [UIViewController]? {
public func pop(animated: Bool = true, completion: (()->())? = nil) -> [UIViewController]? {
guard let stack = navigationController?.viewControllers , stack.count > 1 else {
AppRouter.print("#[AppRouter] can't pop \"\(String(describing: self))\" when only one controller in navigation stack!")
return nil
Expand All @@ -45,7 +45,7 @@ extension UIViewController {
/// - parameter completion: Called after transition ends successfully.
/// - returns: [UIViewCotnroller]? - returns the popped controllers
@discardableResult
public func pop(completion: Func<Void, Void>?) -> [UIViewController]? {
public func pop(completion: (()->())?) -> [UIViewController]? {
return pop(animated: true, completion: completion)
}

Expand All @@ -63,7 +63,7 @@ extension UIViewController {
/// - parameter completion: Called after transition ends successfully
/// - returns: returns true if able to close
@discardableResult
public func close(animated: Bool, completion: Func<Void, Void>? = nil) -> Bool {
public func close(animated: Bool, completion: (()->())? = nil) -> Bool {
if canPop() {
_ = pop(animated: animated, completion: completion)
} else if isModal {
Expand All @@ -80,7 +80,7 @@ extension UIViewController {
/// - parameter completion: Called after transition ends successfully
/// - returns: returns true if able to close
@discardableResult
public func close(completion: Func<Void, Void>?) -> Bool {
public func close(completion: (()->())?) -> Bool {
return close(animated: true, completion: completion)
}

Expand Down Expand Up @@ -138,7 +138,7 @@ extension UINavigationController {
/// - parameter viewController: controller to be pushed
/// - parameter animated: Set this value to true to animate the transition
/// - parameter completion: Called after transition ends successfully
public func pushViewController(_ viewController: UIViewController, animated: Bool, completion: Func<Void, Void>?) {
public func pushViewController(_ viewController: UIViewController, animated: Bool, completion: (()->())?) {
guard !viewControllers.contains(viewController) else { return AppRouter.print("#[AppRouter] can't push \"\(String(describing: type(of: viewController)))\", already in navigation stack!") }
pushViewController(viewController, animated: animated)
_сoordinator(animated, completion: completion)
Expand All @@ -150,7 +150,7 @@ extension UINavigationController {
/// - parameter completion: Called after transition ends successfully
/// - returns: the popped controller
@discardableResult
public func popViewController(animated: Bool, completion: Func<Void, Void>?) -> UIViewController? {
public func popViewController(animated: Bool, completion: (()->())?) -> UIViewController? {
guard let popped = self.popViewController(animated: animated) else { return nil }
_сoordinator(animated, completion: completion)
return popped
Expand All @@ -163,7 +163,7 @@ extension UINavigationController {
/// - parameter completion: Called after transition ends successfully
/// - returns: [UIViewCotnroller]? - returns the popped controllers
@discardableResult
public func popToViewController(_ viewController: UIViewController, animated: Bool, completion: Func<Void, Void>?) -> [UIViewController]? {
public func popToViewController(_ viewController: UIViewController, animated: Bool, completion: (()->())?) -> [UIViewController]? {
guard let popped = popToViewController(viewController, animated: animated) else { return nil }
_сoordinator(animated, completion: completion)
return popped
Expand All @@ -176,7 +176,7 @@ extension UINavigationController {
/// - parameter completion: Called after transition ends successfully
/// - returns: [UIViewCotnroller]? - returns the popped controllers
@discardableResult
public func popToViewController<T: UIViewController>(_ type: T.Type, animated: Bool, completion: Func<Void, Void>?) -> [UIViewController]? {
public func popToViewController<T: UIViewController>(_ type: T.Type, animated: Bool, completion: (()->())?) -> [UIViewController]? {
guard let popped = popToViewController(type, animated: animated) else { return nil }
_сoordinator(animated, completion: completion)
return popped
Expand All @@ -188,19 +188,19 @@ extension UINavigationController {
/// - parameter completion: Called after transition ends successfully
/// - returns: [UIViewCotnroller]? - returns the popped controllers
@discardableResult
public func popToRootViewController(animated: Bool, completion: Func<Void, Void>?) -> [UIViewController]? {
public func popToRootViewController(animated: Bool, completion: (()->())?) -> [UIViewController]? {
guard let popped = self.popToRootViewController(animated: animated) else { return nil }
_сoordinator(animated, completion: completion)
return popped
}

fileprivate func _сoordinator(_ animated: Bool, completion: Func<Void, Void>?) {
fileprivate func _сoordinator(_ animated: Bool, completion: (()->())?) {
if let coordinator = transitionCoordinator , animated {
coordinator.animate(alongsideTransition: nil) { _ in
completion?(())
completion?()
}
} else {
completion?(())
completion?()
}
}
}
6 changes: 3 additions & 3 deletions Sources/Core/AppRouter+presenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ extension AppRouter.Presenter {
/// - parameter completion: The block to execute after the view controller is pushed.
/// - returns: returns instance provided by `source` provider
@discardableResult
open func push(animated: Bool, completion: Func<Void, Void>? = nil) throws -> T {
open func push(animated: Bool, completion: (()->())? = nil) throws -> T {
let embedded = try provideEmbeddedSourceController()
guard !(embedded.parent is UINavigationController) else { throw Errors.tryingToPushNavigationController }
let targetController = try performTargetConstruction() as UIViewController
Expand All @@ -168,7 +168,7 @@ extension AppRouter.Presenter {
/// - parameter completion: The block to execute after the view controller is presented.
/// - returns: returns instance provided by `source` provider
@discardableResult
open func present(animated: Bool, completion: Func<Void, Void>? = nil) throws -> T {
open func present(animated: Bool, completion: (()->())? = nil) throws -> T {
let embedded = try provideEmbeddedSourceController()
let targetController = try performTargetConstruction() as UIViewController
targetController.present(embedded.parent, animated: animated, completion: completion)
Expand All @@ -189,7 +189,7 @@ extension AppRouter.Presenter {
/// - parameter completion: The block to execute after the view controller is setted.
/// - returns: returns instance provided by `source` provider
@discardableResult
open func setAsRoot(animation: AppRouter.Animators.AnimationType, completion: Func<Bool, Void>? = nil) throws -> T {
open func setAsRoot(animation: AppRouter.Animators.AnimationType, completion: ((Bool)->())? = nil) throws -> T {
let embedded = try provideEmbeddedSourceController()
router.animator.setRoot(controller: embedded.parent, animation: animation, callback: completion)
return embedded.child
Expand Down
Loading

0 comments on commit 2c57b3e

Please sign in to comment.