From 06b0d08ddc93b3207082c43b87cd2227802a0639 Mon Sep 17 00:00:00 2001 From: Anna Sahaidak Date: Tue, 31 Mar 2020 14:12:23 +0300 Subject: [PATCH 1/3] Migrate to swift 5 --- .../project.pbxproj | 36 +++- .../Base.lproj/Main.storyboard | 190 +++++++----------- .../Circular/CircularRevealAnimator.swift | 2 +- .../Controller/IntroViewController.swift | 6 +- .../MainSettingsViewController.swift | 4 +- .../View/StarsOverlay.swift | 6 +- .../StarWarsGLAnimator.swift | 8 +- .../StarWarsUIDynamicAnimator.swift | 2 +- .../StarWarsUIViewAnimator.swift | 6 +- 9 files changed, 115 insertions(+), 145 deletions(-) diff --git a/Example/StarWarsAnimations.xcodeproj/project.pbxproj b/Example/StarWarsAnimations.xcodeproj/project.pbxproj index 8f8b972..039aaa7 100644 --- a/Example/StarWarsAnimations.xcodeproj/project.pbxproj +++ b/Example/StarWarsAnimations.xcodeproj/project.pbxproj @@ -306,22 +306,22 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1140; ORGANIZATIONNAME = Yalantis; TargetAttributes = { 2A89D8941BD6633300A2C503 = { CreatedOnToolsVersion = 7.0.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 1140; }; 2ACECE361BA2BF2E005689AD = { CreatedOnToolsVersion = 7.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 1140; }; }; }; buildConfigurationList = 2ACECE321BA2BF2E005689AD /* Build configuration list for PBXProject "StarWarsAnimations" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -441,7 +441,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -464,7 +465,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars.Animation; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -478,14 +480,22 @@ 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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; @@ -525,14 +535,22 @@ 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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; @@ -569,7 +587,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -584,7 +603,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Example/StarWarsAnimations/Base.lproj/Main.storyboard b/Example/StarWarsAnimations/Base.lproj/Main.storyboard index 0e145fa..a6a133e 100644 --- a/Example/StarWarsAnimations/Base.lproj/Main.storyboard +++ b/Example/StarWarsAnimations/Base.lproj/Main.storyboard @@ -1,59 +1,46 @@ - - + + + - - + + - + GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - GothamPro - + - + - + - - + + - - - + - - + @@ -104,8 +87,7 @@ - - + @@ -125,40 +107,37 @@ - + - + - - + - - + @@ -189,47 +168,42 @@ - + - + - - - + + - + - - + - + - + - - - + + - @@ -239,31 +213,27 @@ - - + - + - @@ -274,31 +244,27 @@ - - + - + - @@ -309,31 +275,27 @@ - - + - + - @@ -344,46 +306,39 @@ - - + - + - - - @@ -399,7 +354,6 @@ - @@ -440,11 +394,9 @@ - - - + @@ -453,8 +405,7 @@ - - + @@ -470,12 +421,11 @@ - + - - + - + diff --git a/Example/StarWarsAnimations/Circular/CircularRevealAnimator.swift b/Example/StarWarsAnimations/Circular/CircularRevealAnimator.swift index 96b078f..d41ab54 100644 --- a/Example/StarWarsAnimations/Circular/CircularRevealAnimator.swift +++ b/Example/StarWarsAnimations/Circular/CircularRevealAnimator.swift @@ -48,7 +48,7 @@ class CircularRevealAnimator { mask = CAShapeLayer() mask.path = endPath - mask.fillRule = kCAFillRuleEvenOdd + mask.fillRule = CAShapeLayerFillRule.evenOdd animation = CABasicAnimation(keyPath: "path") animation.fromValue = startPath diff --git a/Example/StarWarsAnimations/Controller/IntroViewController.swift b/Example/StarWarsAnimations/Controller/IntroViewController.swift index 40fd096..c3194bb 100644 --- a/Example/StarWarsAnimations/Controller/IntroViewController.swift +++ b/Example/StarWarsAnimations/Controller/IntroViewController.swift @@ -52,8 +52,8 @@ class IntroViewController: UIViewController { extension IntroViewController: UIViewControllerTransitioningDelegate { func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { -// return StarWarsUIDynamicAnimator() -// return StarWarsUIViewAnimator() - return StarWarsGLAnimator() +// StarWarsUIDynamicAnimator() +// StarWarsUIViewAnimator() + StarWarsGLAnimator() } } diff --git a/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift b/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift index 42bf1e3..e2b8228 100644 --- a/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift +++ b/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift @@ -29,8 +29,8 @@ class MainSettingsViewController: UIViewController { navigationController!.navigationBar.shadowImage = UIImage() navigationController!.navigationBar.isTranslucent = true navigationController!.navigationBar.titleTextAttributes = [ - NSAttributedStringKey.font: UIFont(name: "GothamPro", size: 20)!, - NSAttributedStringKey.foregroundColor: UIColor.white + NSAttributedString.Key.font: UIFont(name: "GothamPro", size: 20)!, + NSAttributedString.Key.foregroundColor: UIColor.white ] } diff --git a/Example/StarWarsAnimations/View/StarsOverlay.swift b/Example/StarWarsAnimations/View/StarsOverlay.swift index 0950995..9e4aa4e 100644 --- a/Example/StarWarsAnimations/View/StarsOverlay.swift +++ b/Example/StarWarsAnimations/View/StarsOverlay.swift @@ -31,9 +31,9 @@ class StarsOverlay: UIView { fileprivate var particle: CAEmitterCell! func setup() { - emitter.emitterMode = kCAEmitterLayerOutline - emitter.emitterShape = kCAEmitterLayerCircle - emitter.renderMode = kCAEmitterLayerOldestFirst + emitter.emitterMode = CAEmitterLayerEmitterMode.outline + emitter.emitterShape = CAEmitterLayerEmitterShape.circle + emitter.renderMode = CAEmitterLayerRenderMode.oldestFirst emitter.preservesDepth = true particle = CAEmitterCell() diff --git a/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift b/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift index f9deb4d..b3efd6b 100644 --- a/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift +++ b/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift @@ -25,7 +25,7 @@ open class StarWarsGLAnimator: NSObject, UIViewControllerAnimatedTransitioning { fileprivate var render: SpriteRender! open func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { - return duration + duration } open func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { @@ -34,7 +34,7 @@ open class StarWarsGLAnimator: NSObject, UIViewControllerAnimatedTransitioning { let toView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!.view containerView.addSubview(toView!) - containerView.sendSubview(toBack: toView!) + containerView.sendSubviewToBack(toView!) func randomFloatBetween(_ smallNumber: CGFloat, and bigNumber: CGFloat) -> Float { let diff = bigNumber - smallNumber @@ -81,9 +81,9 @@ open class StarWarsGLAnimator: NSObject, UIViewControllerAnimatedTransitioning { displayLink = CADisplayLink(target: self, selector: #selector(StarWarsGLAnimator.displayLinkTick(_:))) displayLink.isPaused = false - displayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes) + displayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common) - self.startTransitionTime = Date.timeIntervalSinceReferenceDate + self.startTransitionTime = Date.timeIntervalSinceReferenceDate } open func animationEnded(_ transitionCompleted: Bool) { diff --git a/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift b/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift index e39340b..b12bd10 100644 --- a/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift +++ b/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift @@ -27,7 +27,7 @@ open class StarWarsUIDynamicAnimator: NSObject, UIViewControllerAnimatedTransiti let toView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!.view containerView.addSubview(toView!) - containerView.sendSubview(toBack: toView!) + containerView.sendSubviewToBack(toView!) let size = fromView!.frame.size diff --git a/StarWars/StarWarsUIViewAnimator/StarWarsUIViewAnimator.swift b/StarWars/StarWarsUIViewAnimator/StarWarsUIViewAnimator.swift index 0bd3e1e..4ef320e 100644 --- a/StarWars/StarWarsUIViewAnimator/StarWarsUIViewAnimator.swift +++ b/StarWars/StarWarsUIViewAnimator/StarWarsUIViewAnimator.swift @@ -23,7 +23,7 @@ open class StarWarsUIViewAnimator: NSObject, UIViewControllerAnimatedTransitioni let toView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!.view containerView.addSubview(toView!) - containerView.sendSubview(toBack: toView!) + containerView.sendSubviewToBack(toView!) var snapshots:[UIView] = [] let size = fromView?.frame.size @@ -52,13 +52,13 @@ open class StarWarsUIViewAnimator: NSObject, UIViewControllerAnimatedTransitioni } } - containerView.sendSubview(toBack: fromView!) + containerView.sendSubviewToBack(fromView!) UIView.animate( withDuration: duration, delay: 0, - options: UIViewAnimationOptions.curveLinear, + options: UIView.AnimationOptions.curveLinear, animations: { for view in snapshots { let xOffset = randomFloatBetween(-200 , and: 200) From 4805f5947eb40fe4414fbb9641a068a20374c527 Mon Sep 17 00:00:00 2001 From: Anna Sahaidak Date: Tue, 31 Mar 2020 15:14:08 +0300 Subject: [PATCH 2/3] Fix dismiss transition bug. --- .../StarWarsAnimations/Controller/IntroViewController.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Example/StarWarsAnimations/Controller/IntroViewController.swift b/Example/StarWarsAnimations/Controller/IntroViewController.swift index c3194bb..893caf0 100644 --- a/Example/StarWarsAnimations/Controller/IntroViewController.swift +++ b/Example/StarWarsAnimations/Controller/IntroViewController.swift @@ -42,6 +42,9 @@ class IntroViewController: UIViewController { override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let destination = segue.destination destination.transitioningDelegate = self + if #available(iOS 13.0, *) { + destination.modalPresentationStyle = .fullScreen + } if let navigation = destination as? UINavigationController, let settings = navigation.topViewController as? MainSettingsViewController { settings.theme = .light From 5db8e2acc19971c870ca1640823542f5145dde11 Mon Sep 17 00:00:00 2001 From: Anna Sahaidak Date: Tue, 31 Mar 2020 15:21:25 +0300 Subject: [PATCH 3/3] Update readme and podspec. --- README.md | 7 ++++--- StarWars.podspec | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6d1ff13..1a83449 100644 --- a/README.md +++ b/README.md @@ -36,12 +36,12 @@ Then just implement class of *UIViewControllerTransitioningDelegate* that will r ```swift override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { -let destination = segue.destinationViewController -destination.transitioningDelegate = self + let destination = segue.destinationViewController + destination.transitioningDelegate = self } func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { -return StarWarsGLAnimator() + return StarWarsGLAnimator() } ``` @@ -67,6 +67,7 @@ P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on - `1.0` Swift 2.0 - `2.0` Adds Swift 3.0 support - `3.0` Adds Swift 4.0 support +- `4.0` Adds Swift 5.0 support ## License diff --git a/StarWars.podspec b/StarWars.podspec index 2db313e..fa22173 100644 --- a/StarWars.podspec +++ b/StarWars.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "StarWars" - s.version = "3.0" + s.version = "4.0" s.summary = "This component implements transition animation to crumble view-controller into tiny pieces" s.homepage = "https://yalantis.com/blog/uidynamics-uikit-or-opengl-3-types-of-ios-animations-for-the-star-wars/"