From 2b3cea1b9fca630f4b60e3ccf1eadcd69296252e Mon Sep 17 00:00:00 2001 From: "mengtao.feng" Date: Thu, 21 Jun 2018 11:43:57 +0800 Subject: [PATCH 1/3] fix: make it work on swift4.2 --- Animo.xcodeproj/project.pbxproj | 4 ++-- .../Internal/CAAnimation+AnimoInternals.swift | 2 +- .../Internal/Transition+AnimoInternals.swift | 22 +++++++++---------- Animo/Options.swift | 8 +++---- Animo/TimingMode.swift | 8 +++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Animo.xcodeproj/project.pbxproj b/Animo.xcodeproj/project.pbxproj index deafbf1..663e140 100644 --- a/Animo.xcodeproj/project.pbxproj +++ b/Animo.xcodeproj/project.pbxproj @@ -519,7 +519,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -536,7 +536,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Animo/Internal/CAAnimation+AnimoInternals.swift b/Animo/Internal/CAAnimation+AnimoInternals.swift index f6d2f3b..e12ae71 100644 --- a/Animo/Internal/CAAnimation+AnimoInternals.swift +++ b/Animo/Internal/CAAnimation+AnimoInternals.swift @@ -37,7 +37,7 @@ internal extension CAAnimation { internal func applyOptions(_ options: Options = .default) { self.speed = Float(options.speed) - self.fillMode = options.fillMode + self.fillMode = CAMediaTimingFillMode(rawValue: options.fillMode) self.isRemovedOnCompletion = options.removedOnCompletion } } diff --git a/Animo/Internal/Transition+AnimoInternals.swift b/Animo/Internal/Transition+AnimoInternals.swift index 068c34b..f493fc0 100644 --- a/Animo/Internal/Transition+AnimoInternals.swift +++ b/Animo/Internal/Transition+AnimoInternals.swift @@ -40,30 +40,30 @@ internal extension Transition { switch direction { - case .leftToRight: return kCATransitionFromLeft - case .rightToLeft: return kCATransitionFromRight - case .topToBottom: return kCATransitionFromTop - case .bottomToTop: return kCATransitionFromBottom + case .leftToRight: return CATransitionSubtype.fromLeft.rawValue + case .rightToLeft: return CATransitionSubtype.fromRight.rawValue + case .topToBottom: return CATransitionSubtype.fromTop.rawValue + case .bottomToTop: return CATransitionSubtype.fromBottom.rawValue } } switch self { case .fade: - object.type = kCATransitionFade + object.type = CATransitionType.fade object.subtype = nil case .moveIn(let direction): - object.type = kCATransitionMoveIn - object.subtype = subtypeForCATransition(direction) + object.type = CATransitionType.moveIn + object.subtype = CATransitionSubtype(rawValue: subtypeForCATransition(direction)) case .push(let direction): - object.type = kCATransitionPush - object.subtype = subtypeForCATransition(direction) + object.type = CATransitionType.push + object.subtype = CATransitionSubtype(rawValue: subtypeForCATransition(direction)) case .reveal(let direction): - object.type = kCATransitionReveal - object.subtype = subtypeForCATransition(direction) + object.type = CATransitionType.reveal + object.subtype = CATransitionSubtype(rawValue: subtypeForCATransition(direction)) } } } diff --git a/Animo/Options.swift b/Animo/Options.swift index 5b0eec9..e51d523 100644 --- a/Animo/Options.swift +++ b/Animo/Options.swift @@ -56,10 +56,10 @@ public struct Options { switch fillMode { - case FillMode.forwards: return kCAFillModeForwards - case FillMode.backwards: return kCAFillModeBackwards - case FillMode.both: return kCAFillModeBoth - default: return kCAFillModeRemoved + case FillMode.forwards: return CAMediaTimingFillMode.forwards.rawValue + case FillMode.backwards: return CAMediaTimingFillMode.backwards.rawValue + case FillMode.both: return CAMediaTimingFillMode.both.rawValue + default: return CAMediaTimingFillMode.removed.rawValue } } diff --git a/Animo/TimingMode.swift b/Animo/TimingMode.swift index b51ebaa..12784c3 100644 --- a/Animo/TimingMode.swift +++ b/Animo/TimingMode.swift @@ -57,10 +57,10 @@ public enum TimingMode { switch self { - case .linear: return CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) - case .easeIn: return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) - case .easeOut: return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) - case .easeInOut: return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + case .linear: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) + case .easeIn: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) + case .easeOut: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut) + case .easeInOut: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) case .spring(let damping): return CAMediaTimingFunction(controlPoints: 0.5, 1.1 + (Float(damping) / 3.0), 1, 1) case .discrete: return CAMediaTimingFunction(controlPoints: 1, 0, 1, 1) From 307f9636651ee3ffb2031c6dc89635de7bab5891 Mon Sep 17 00:00:00 2001 From: Jesse Armand Iswaraputra Date: Mon, 10 Dec 2018 18:02:12 +0800 Subject: [PATCH 2/3] Fixed CGFloat degrees to radians conversion It should be .pi instead of .greatestFiniteMagnitude --- Animo/KeyframeValueConvertible.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Animo/KeyframeValueConvertible.swift b/Animo/KeyframeValueConvertible.swift index c2ed53c..4fe7be5 100644 --- a/Animo/KeyframeValueConvertible.swift +++ b/Animo/KeyframeValueConvertible.swift @@ -296,7 +296,7 @@ extension CGFloat: FloatingPointKeyframeValueConvertible { public var degreesToRadians: CGFloat { - return CGFloat(Double.greatestFiniteMagnitude * Double(self) / 180.0) + return CGFloat(Double.pi * Double(self) / 180.0) } } From 728c39d8f6b0cbd1c364f1b6a61d028a1eddfa4d Mon Sep 17 00:00:00 2001 From: Jesse Armand Iswaraputra Date: Tue, 11 Dec 2018 12:21:10 +0800 Subject: [PATCH 3/3] Migrated both ios and osx targets to Swift 4.2 --- Animo.xcodeproj/project.pbxproj | 10 ++-------- Animo/KeyframeValueConvertible.swift | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Animo.xcodeproj/project.pbxproj b/Animo.xcodeproj/project.pbxproj index 663e140..9784df3 100644 --- a/Animo.xcodeproj/project.pbxproj +++ b/Animo.xcodeproj/project.pbxproj @@ -443,7 +443,7 @@ SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -498,7 +498,7 @@ SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -519,7 +519,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -536,7 +535,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; }; name = Release; }; @@ -547,7 +545,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = jp.eure.ios.AnimoTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -558,7 +555,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = jp.eure.ios.AnimoTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; }; name = Release; }; @@ -576,7 +572,6 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -594,7 +589,6 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Animo/KeyframeValueConvertible.swift b/Animo/KeyframeValueConvertible.swift index 4fe7be5..e0ae575 100644 --- a/Animo/KeyframeValueConvertible.swift +++ b/Animo/KeyframeValueConvertible.swift @@ -233,18 +233,18 @@ extension NSObject: KeyframeValueConvertible { var points = Array(repeating: .zero, count: 3) switch self.element(at: index, associatedPoints: &points) { - case .moveToBezierPathElement: + case .moveTo: path.move(to: points[0]) - case .lineToBezierPathElement: + case .lineTo: path.addLine(to: points[0]) didClosePath = false - case .curveToBezierPathElement: + case .curveTo: path.addCurve(to: points[0], control1: points[1], control2: points[2]) didClosePath = false - case .closePathBezierPathElement: + case .closePath: path.closeSubpath() didClosePath = true }