From 401c7175e83c363b4bd6806ff1cfc881a548395b Mon Sep 17 00:00:00 2001 From: "karthikeyan.g" Date: Mon, 13 Aug 2018 14:25:43 +0530 Subject: [PATCH 1/2] Updates code to support Swift 4.2. --- EasyAnimation.xcodeproj/project.pbxproj | 14 +++-- EasyAnimation/EAAnimationFuture.swift | 8 +-- EasyAnimation/EasyAnimation.swift | 60 +++++++++---------- .../RBBSpringAnimation.swift | 2 +- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/EasyAnimation.xcodeproj/project.pbxproj b/EasyAnimation.xcodeproj/project.pbxproj index 6ac3938..c292f32 100644 --- a/EasyAnimation.xcodeproj/project.pbxproj +++ b/EasyAnimation.xcodeproj/project.pbxproj @@ -174,6 +174,7 @@ TargetAttributes = { 403482531B8E01ED006C3C7C = { CreatedOnToolsVersion = 6.4; + DevelopmentTeam = B74NE7DB34; DevelopmentTeamName = "Bakken & Bæck AS"; LastSwiftMigration = 0800; }; @@ -343,8 +344,9 @@ 4034826B1B8E01ED006C3C7C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = B74NE7DB34; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -355,7 +357,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.easyanimation.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -363,7 +365,7 @@ isa = XCBuildConfiguration; buildSettings = { DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = B74NE7DB34; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -375,7 +377,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -394,7 +396,7 @@ PRODUCT_NAME = EasyAnimation; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -416,7 +418,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; diff --git a/EasyAnimation/EAAnimationFuture.swift b/EasyAnimation/EAAnimationFuture.swift index dabf98a..356aedb 100644 --- a/EasyAnimation/EAAnimationFuture.swift +++ b/EasyAnimation/EAAnimationFuture.swift @@ -41,7 +41,7 @@ public class EAAnimationFuture: Equatable, CustomStringConvertible { /* animation properties */ var duration: CFTimeInterval = 0.0 var delay: CFTimeInterval = 0.0 - var options: UIViewAnimationOptions = [] + var options: UIView.AnimationOptions = [] var animations: (() -> Void)? var completion: ((Bool) -> Void)? @@ -101,12 +101,12 @@ public class EAAnimationFuture: Equatable, CustomStringConvertible { } @discardableResult - public func animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public func animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { return animateAndChain(withDuration: duration, delay: delay, options: options, animations: animations, completion: completion) } @discardableResult - public func animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public func animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { let anim = animateAndChain(withDuration: duration, delay: delay, options: options, animations: animations, completion: completion) self.springDamping = dampingRatio self.springVelocity = velocity @@ -114,7 +114,7 @@ public class EAAnimationFuture: Equatable, CustomStringConvertible { } @discardableResult - public func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { var options = options if options.contains(.repeat) { diff --git a/EasyAnimation/EasyAnimation.swift b/EasyAnimation/EasyAnimation.swift index a66a8a5..9622f52 100644 --- a/EasyAnimation/EasyAnimation.swift +++ b/EasyAnimation/EasyAnimation.swift @@ -38,7 +38,7 @@ private class AnimationContext { var duration: TimeInterval = 1.0 var currentTime: TimeInterval = {CACurrentMediaTime()}() var delay: TimeInterval = 0.0 - var options: UIViewAnimationOptions? = nil + var options: UIView.AnimationOptions? = nil var pendingAnimations = [PendingAnimation]() //spring additions @@ -110,16 +110,16 @@ private let specializedLayerKeys: [String: [String]] = [ CATextLayer.self.description(): ["fontSize", "foregroundColor"] ] -public extension UIViewAnimationOptions { +public extension UIView.AnimationOptions { //CA Fill modes - static let fillModeNone = UIViewAnimationOptions(rawValue: 0) - static let fillModeForwards = UIViewAnimationOptions(rawValue: 1024) - static let fillModeBackwards = UIViewAnimationOptions(rawValue: 2048) - static let fillModeBoth = UIViewAnimationOptions(rawValue: 1024 + 2048) + static let fillModeNone = UIView.AnimationOptions(rawValue: 0) + static let fillModeForwards = UIView.AnimationOptions(rawValue: 1024) + static let fillModeBackwards = UIView.AnimationOptions(rawValue: 2048) + static let fillModeBoth = UIView.AnimationOptions(rawValue: 1024 + 2048) //CA Remove on completion - static let isRemovedOnCompletion = UIViewAnimationOptions(rawValue: 0) - static let isNotRemovedOnCompletion = UIViewAnimationOptions(rawValue: 16384) + static let isRemovedOnCompletion = UIView.AnimationOptions(rawValue: 0) + static let isNotRemovedOnCompletion = UIView.AnimationOptions(rawValue: 16384) } /** @@ -200,7 +200,7 @@ extension UIView { } @objc - class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { + class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { //create context let context = AnimationContext() context.duration = duration @@ -240,7 +240,7 @@ extension UIView { } @objc - class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { + class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { //create context let context = AnimationContext() @@ -348,45 +348,45 @@ extension UIView { if context.delay > 0.0 { anim.beginTime = context.currentTime + context.delay - anim.fillMode = kCAFillModeBackwards + anim.fillMode = CAMediaTimingFillMode.backwards } //options if let options = context.options?.rawValue { - if options & UIViewAnimationOptions.beginFromCurrentState.rawValue == 0 { //only repeat if not in a chain - anim.autoreverses = (options & UIViewAnimationOptions.autoreverse.rawValue == UIViewAnimationOptions.autoreverse.rawValue) - anim.repeatCount = (options & UIViewAnimationOptions.repeat.rawValue == UIViewAnimationOptions.repeat.rawValue) ? Float.infinity : 0 + if options & UIView.AnimationOptions.beginFromCurrentState.rawValue == 0 { //only repeat if not in a chain + anim.autoreverses = (options & UIView.AnimationOptions.autoreverse.rawValue == UIView.AnimationOptions.autoreverse.rawValue) + anim.repeatCount = (options & UIView.AnimationOptions.repeat.rawValue == UIView.AnimationOptions.repeat.rawValue) ? Float.infinity : 0 } //easing - var timingFunctionName = kCAMediaTimingFunctionEaseInEaseOut + var timingFunctionName = CAMediaTimingFunctionName.easeInEaseOut - if options & UIViewAnimationOptions.curveLinear.rawValue == UIViewAnimationOptions.curveLinear.rawValue { + if options & UIView.AnimationOptions.curveLinear.rawValue == UIView.AnimationOptions.curveLinear.rawValue { //first check for linear (it's this way to take up only 2 bits) - timingFunctionName = kCAMediaTimingFunctionLinear - } else if options & UIViewAnimationOptions.curveEaseIn.rawValue == UIViewAnimationOptions.curveEaseIn.rawValue { - timingFunctionName = kCAMediaTimingFunctionEaseIn - } else if options & UIViewAnimationOptions.curveEaseOut.rawValue == UIViewAnimationOptions.curveEaseOut.rawValue { - timingFunctionName = kCAMediaTimingFunctionEaseOut + timingFunctionName = CAMediaTimingFunctionName.linear + } else if options & UIView.AnimationOptions.curveEaseIn.rawValue == UIView.AnimationOptions.curveEaseIn.rawValue { + timingFunctionName = CAMediaTimingFunctionName.easeIn + } else if options & UIView.AnimationOptions.curveEaseOut.rawValue == UIView.AnimationOptions.curveEaseOut.rawValue { + timingFunctionName = CAMediaTimingFunctionName.easeOut } anim.timingFunction = CAMediaTimingFunction(name: timingFunctionName) //fill mode - if options & UIViewAnimationOptions.fillModeBoth.rawValue == UIViewAnimationOptions.fillModeBoth.rawValue { + if options & UIView.AnimationOptions.fillModeBoth.rawValue == UIView.AnimationOptions.fillModeBoth.rawValue { //both - anim.fillMode = kCAFillModeBoth - } else if options & UIViewAnimationOptions.fillModeForwards.rawValue == UIViewAnimationOptions.fillModeForwards.rawValue { + anim.fillMode = CAMediaTimingFillMode.both + } else if options & UIView.AnimationOptions.fillModeForwards.rawValue == UIView.AnimationOptions.fillModeForwards.rawValue { //forward - anim.fillMode = (anim.fillMode == kCAFillModeBackwards) ? kCAFillModeBoth : kCAFillModeForwards - } else if options & UIViewAnimationOptions.fillModeBackwards.rawValue == UIViewAnimationOptions.fillModeBackwards.rawValue { + anim.fillMode = (anim.fillMode == CAMediaTimingFillMode.backwards) ? CAMediaTimingFillMode.both : CAMediaTimingFillMode.forwards + } else if options & UIView.AnimationOptions.fillModeBackwards.rawValue == UIView.AnimationOptions.fillModeBackwards.rawValue { //backwards - anim.fillMode = kCAFillModeBackwards + anim.fillMode = CAMediaTimingFillMode.backwards } //is removed on completion - if options & UIViewAnimationOptions.isNotRemovedOnCompletion.rawValue == UIViewAnimationOptions.isNotRemovedOnCompletion.rawValue { + if options & UIView.AnimationOptions.isNotRemovedOnCompletion.rawValue == UIView.AnimationOptions.isNotRemovedOnCompletion.rawValue { anim.isRemovedOnCompletion = false } else { anim.isRemovedOnCompletion = true @@ -409,7 +409,7 @@ extension UIView { :returns: The created request. */ - public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { let currentAnimation = EAAnimationFuture() currentAnimation.duration = duration @@ -440,7 +440,7 @@ extension UIView { :returns: The created request. */ - public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { let currentAnimation = EAAnimationFuture() currentAnimation.duration = duration diff --git a/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift b/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift index 74c5d69..9ff5dcb 100644 --- a/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift +++ b/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift @@ -66,7 +66,7 @@ class RBBSpringAnimation: CAKeyframeAnimation { mass = 1 stiffness = 100 - calculationMode = kCAAnimationDiscrete + calculationMode = CAAnimationCalculationMode.discrete } required init(coder aDecoder: NSCoder) { From 6a220b3b7e6886998f98c98951e3befc3a31d891 Mon Sep 17 00:00:00 2001 From: "karthikeyan.g" Date: Mon, 13 Aug 2018 14:29:43 +0530 Subject: [PATCH 2/2] Sets development team to None. --- EasyAnimation.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/EasyAnimation.xcodeproj/project.pbxproj b/EasyAnimation.xcodeproj/project.pbxproj index c292f32..43ca1e5 100644 --- a/EasyAnimation.xcodeproj/project.pbxproj +++ b/EasyAnimation.xcodeproj/project.pbxproj @@ -174,12 +174,10 @@ TargetAttributes = { 403482531B8E01ED006C3C7C = { CreatedOnToolsVersion = 6.4; - DevelopmentTeam = B74NE7DB34; DevelopmentTeamName = "Bakken & Bæck AS"; LastSwiftMigration = 0800; }; 72A03EEA1C29784A002DA467 = { - DevelopmentTeam = 29X3GG489T; DevelopmentTeamName = "Bakken & Bæck AS"; }; }; @@ -346,7 +344,7 @@ buildSettings = { CODE_SIGN_IDENTITY = "iPhone Developer"; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = B74NE7DB34; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -365,7 +363,7 @@ isa = XCBuildConfiguration; buildSettings = { DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = B74NE7DB34; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -385,6 +383,7 @@ isa = XCBuildConfiguration; buildSettings = { DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -406,6 +405,7 @@ isa = XCBuildConfiguration; buildSettings = { DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath";