diff --git a/C4.xcodeproj/project.pbxproj b/C4.xcodeproj/project.pbxproj index 3feed7ad..389fee52 100644 --- a/C4.xcodeproj/project.pbxproj +++ b/C4.xcodeproj/project.pbxproj @@ -662,17 +662,17 @@ }; 614F824219DB5ED3001DF1D4 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; }; 614F824D19DB5ED4001DF1D4 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; TestTargetID = A96F50591B5385A5002B3A46; }; A96F50591B5385A5002B3A46 = { CreatedOnToolsVersion = 6.4; DevelopmentTeam = 75C7KVJZ99; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; }; }; }; @@ -1016,7 +1016,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1047,7 +1046,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1071,7 +1069,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1096,7 +1093,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1155,7 +1151,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 = ""; @@ -1206,7 +1202,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; 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"; diff --git a/C4/UI/AudioPlayer.swift b/C4/UI/AudioPlayer.swift index aa48373f..407efb89 100644 --- a/C4/UI/AudioPlayer.swift +++ b/C4/UI/AudioPlayer.swift @@ -48,7 +48,9 @@ public class AudioPlayer: NSObject, AVAudioPlayerDelegate { /// ```` public init?(_ name: String) { do { - try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) + if #available(iOS 10.0, tvOS 10.0, *) { + try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default) + } try AVAudioSession.sharedInstance().setActive(true) } catch { print("Couldn't set up AVAudioSession") diff --git a/C4/UI/Camera.swift b/C4/UI/Camera.swift index 3f62f6a1..c5a58603 100644 --- a/C4/UI/Camera.swift +++ b/C4/UI/Camera.swift @@ -66,7 +66,7 @@ public class Camera: View { previewLayer.backgroundColor = clear.cgColor previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill - orientationObserver = on(event: NSNotification.Name.UIDeviceOrientationDidChange) { [unowned self] in + orientationObserver = on(event: UIDevice.orientationDidChangeNotification) { [unowned self] in self.updateOrientation() } } @@ -191,7 +191,7 @@ public class Camera: View { return image } - var orientation: UIImageOrientation + var orientation: UIImage.Orientation let shouldFlip = position == .front switch videoOrientation { diff --git a/C4/UI/Movie.swift b/C4/UI/Movie.swift index 83a9bb09..12a5c8d2 100644 --- a/C4/UI/Movie.swift +++ b/C4/UI/Movie.swift @@ -142,7 +142,9 @@ public class Movie: View { /// - parameter filename: The name of the movie file included in your project. public convenience init?(_ filename: String) { do { - try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) + if #available(iOS 10.0, tvOS 10.0, *) { + try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default) + } try AVAudioSession.sharedInstance().setActive(true) } catch { print("Couldn't set up AVAudioSession") @@ -225,7 +227,7 @@ public class Movie: View { print("The current movie's player is not properly initialized") return } - p.seek(to: CMTimeMake(0, 1)) + p.seek(to: CMTimeMake(value: 0, timescale: 1)) p.pause() } diff --git a/C4/UI/Shape.swift b/C4/UI/Shape.swift index d30fc591..2f4697e6 100644 --- a/C4/UI/Shape.swift +++ b/C4/UI/Shape.swift @@ -41,7 +41,7 @@ open class Shape: View { return nil } - let fillRule = shapeLayer.fillRule == kCAFillRuleNonZero ? CGPathFillRule.evenOdd : CGPathFillRule.winding + let fillRule = shapeLayer.fillRule == .nonZero ? CGPathFillRule.evenOdd : CGPathFillRule.winding if path.contains(point, using: fillRule, transform: CGAffineTransform.identity) { return self @@ -216,9 +216,9 @@ open class Shape: View { public var fillRule: FillRule { get { switch shapeLayer.fillRule { - case kCAFillRuleNonZero: + case .nonZero: return .nonZero - case kCAFillRuleEvenOdd: + case .evenOdd: return .evenOdd default: return .nonZero @@ -227,9 +227,9 @@ open class Shape: View { set(fillRule) { switch fillRule { case .nonZero: - shapeLayer.fillRule = kCAFillRuleNonZero + shapeLayer.fillRule = .nonZero case .evenOdd: - shapeLayer.fillRule = kCAFillRuleEvenOdd + shapeLayer.fillRule = .evenOdd } } } @@ -275,9 +275,9 @@ open class Shape: View { public var lineCap: LineCap { get { switch shapeLayer.lineCap { - case kCALineCapRound: + case .round: return .round - case kCALineCapSquare: + case .square: return .square default: return .butt @@ -286,11 +286,11 @@ open class Shape: View { set(lineCap) { switch lineCap { case .butt: - shapeLayer.lineCap = kCALineCapButt + shapeLayer.lineCap = .butt case .round: - shapeLayer.lineCap = kCALineCapRound + shapeLayer.lineCap = .round case .square: - shapeLayer.lineCap = kCALineCapSquare + shapeLayer.lineCap = .square } } } @@ -299,9 +299,9 @@ open class Shape: View { public var lineJoin: LineJoin { get { switch shapeLayer.lineJoin { - case kCALineJoinRound: + case .round: return .round - case kCALineJoinBevel: + case .bevel: return .bevel default: return .miter @@ -310,11 +310,11 @@ open class Shape: View { set(lineJoin) { switch lineJoin { case .miter: - shapeLayer.lineJoin = kCALineJoinMiter + shapeLayer.lineJoin = .miter case .round: - shapeLayer.lineJoin = kCALineJoinRound + shapeLayer.lineJoin = .round case .bevel: - shapeLayer.lineJoin = kCALineJoinBevel + shapeLayer.lineJoin = .bevel } } } diff --git a/C4/UI/ShapeLayer.swift b/C4/UI/ShapeLayer.swift index fada523a..fdfe9755 100644 --- a/C4/UI/ShapeLayer.swift +++ b/C4/UI/ShapeLayer.swift @@ -132,7 +132,7 @@ extension CABasicAnimation { self.autoreverses = animation.autoreverses self.repeatCount = Float(animation.repeatCount) } - self.fillMode = kCAFillModeBoth + self.fillMode = .both self.isRemovedOnCompletion = false } } diff --git a/C4/UI/StoredAnimation.swift b/C4/UI/StoredAnimation.swift index b05f9f7f..aecee79f 100644 --- a/C4/UI/StoredAnimation.swift +++ b/C4/UI/StoredAnimation.swift @@ -34,21 +34,21 @@ public class StoredAnimation: Animation { let disable = ShapeLayer.disableActions ShapeLayer.disableActions = false var timing: CAMediaTimingFunction - var options: UIViewAnimationOptions = [UIViewAnimationOptions.beginFromCurrentState] + var options: UIView.AnimationOptions = [.beginFromCurrentState] switch curve { case .linear: options = [options, .curveLinear] - timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) + timing = CAMediaTimingFunction(name: .linear) case .easeOut: options = [options, .curveEaseOut] - timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) + timing = CAMediaTimingFunction(name: .easeOut) case .easeIn: options = [options, .curveEaseIn] - timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) + timing = CAMediaTimingFunction(name: .easeIn) case .easeInOut: options = [options, .curveEaseIn, .curveEaseOut] - timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + timing = CAMediaTimingFunction(name: .easeInEaseOut) } autoreverses == true ? options.formUnion(.autoreverse) : options.subtract(.autoreverse) diff --git a/C4/UI/Timer.swift b/C4/UI/Timer.swift index d4147358..30d441af 100644 --- a/C4/UI/Timer.swift +++ b/C4/UI/Timer.swift @@ -64,7 +64,7 @@ public final class Timer: NSObject { } let t = Foundation.Timer(timeInterval: TimeInterval(interval), target: self, selector: #selector(Timer.fire), userInfo: nil, repeats: true) - RunLoop.main.add(t, forMode: RunLoopMode.defaultRunLoopMode) + RunLoop.main.add(t, forMode: .default) timer = t } diff --git a/C4/UI/UIGestureRecognizer+Closure.swift b/C4/UI/UIGestureRecognizer+Closure.swift index e62bea3f..8328135e 100644 --- a/C4/UI/UIGestureRecognizer+Closure.swift +++ b/C4/UI/UIGestureRecognizer+Closure.swift @@ -66,7 +66,7 @@ extension UIGestureRecognizer { } } -public typealias TapAction = (_ locations: [Point], _ center: Point, _ state: UIGestureRecognizerState) -> Void +public typealias TapAction = (_ locations: [Point], _ center: Point, _ state: UIGestureRecognizer.State) -> Void extension UITapGestureRecognizer { /// The closure to call when there is a gesture event. @@ -107,7 +107,7 @@ extension UITapGestureRecognizer { } } -public typealias PanAction = (_ locations: [Point], _ center: Point, _ translation: Vector, _ velocity: Vector, _ state: UIGestureRecognizerState) -> Void +public typealias PanAction = (_ locations: [Point], _ center: Point, _ translation: Vector, _ velocity: Vector, _ state: UIGestureRecognizer.State) -> Void extension UIPanGestureRecognizer { /// The closure to call when there is a gesture event. @@ -166,7 +166,7 @@ extension UIPanGestureRecognizer { } } -public typealias PinchAction = (_ locations: [Point], _ center: Point, _ scale: Double, _ velocity: Double, _ state: UIGestureRecognizerState) -> Void +public typealias PinchAction = (_ locations: [Point], _ center: Point, _ scale: Double, _ velocity: Double, _ state: UIGestureRecognizer.State) -> Void extension UIPinchGestureRecognizer { /// The closure to call when there is a gesture event. @@ -207,7 +207,7 @@ extension UIPinchGestureRecognizer { } } -public typealias RotationAction = (_ rotation: Double, _ velocity: Double, _ state: UIGestureRecognizerState) -> Void +public typealias RotationAction = (_ rotation: Double, _ velocity: Double, _ state: UIGestureRecognizer.State) -> Void extension UIRotationGestureRecognizer { /// The closure to call when there is a gesture event. @@ -244,7 +244,7 @@ extension UIRotationGestureRecognizer { } } -public typealias LongPressAction = (_ locations: [Point], _ center: Point, _ state: UIGestureRecognizerState) -> Void +public typealias LongPressAction = (_ locations: [Point], _ center: Point, _ state: UIGestureRecognizer.State) -> Void extension UILongPressGestureRecognizer { /// The closure to call when there is a gesture event. @@ -285,7 +285,7 @@ extension UILongPressGestureRecognizer { } } -public typealias SwipeAction = (_ locations: [Point], _ center: Point, _ state: UIGestureRecognizerState, _ direction: UISwipeGestureRecognizerDirection) -> Void +public typealias SwipeAction = (_ locations: [Point], _ center: Point, _ state: UIGestureRecognizer.State, _ direction: UISwipeGestureRecognizer.Direction) -> Void extension UISwipeGestureRecognizer { /// The closure to call when there is a gesture event. @@ -326,7 +326,7 @@ extension UISwipeGestureRecognizer { } } -public typealias ScreenEdgePanAction = (_ location: Point, _ state: UIGestureRecognizerState) -> Void +public typealias ScreenEdgePanAction = (_ location: Point, _ state: UIGestureRecognizer.State) -> Void extension UIScreenEdgePanGestureRecognizer { /// The closure to call when there is a gesture event. diff --git a/C4/UI/UIView+AddRemove.swift b/C4/UI/UIView+AddRemove.swift index 64d2e46c..731cde6a 100644 --- a/C4/UI/UIView+AddRemove.swift +++ b/C4/UI/UIView+AddRemove.swift @@ -72,9 +72,9 @@ extension UIView { /// - parameter subview: The subview to move to the back. public func sendToBack(_ subview: T?) { if let v = subview as? UIView { - self.sendSubview(toBack: v) + self.sendSubviewToBack(v) } else if let v = subview as? View { - self.sendSubview(toBack: v.view) + self.sendSubviewToBack(v.view) } else { fatalError("Can't operate on subview of class `\(type(of: subview))`") } @@ -85,9 +85,9 @@ extension UIView { /// - parameter subview: The subview to move to the front. public func bringToFront(_ subview: T?) { if let v = subview as? UIView { - self.bringSubview(toFront: v) + self.bringSubviewToFront(v) } else if let v = subview as? View { - self.bringSubview(toFront: v.view) + self.bringSubviewToFront(v.view) } else { fatalError("Can't operate on subview of class `\(type(of: subview))`") } diff --git a/C4/UI/View+Animation.swift b/C4/UI/View+Animation.swift index 7bd961d0..818e41ab 100644 --- a/C4/UI/View+Animation.swift +++ b/C4/UI/View+Animation.swift @@ -61,7 +61,7 @@ public extension View { /// - parameter options: Options for animating views using block objects, see: UIViewAnimationOptions. /// - parameter animations: A block of code with specified animations to execute. /// - parameter completion: A block of code to execute when the animation completes. - public class func animate(duration: Double, delay: Double, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) { + public class func animate(duration: Double, delay: Double, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) { UIView.animate(withDuration: duration, delay: delay, options: options, animations: animations, completion: completion) } } diff --git a/C4/UI/View.swift b/C4/UI/View.swift index 0faf73a1..271d0163 100644 --- a/C4/UI/View.swift +++ b/C4/UI/View.swift @@ -375,9 +375,9 @@ open class View: NSObject { /// - parameter subview: The subview to move to the back. public func sendToBack(_ subview: T?) { if let v = subview as? UIView { - view.sendSubview(toBack: v) + view.sendSubviewToBack(v) } else if let v = subview as? View { - view.sendSubview(toBack: v.view) + view.sendSubviewToBack(v.view) } else { fatalError("Can't operate on subview of class `\(type(of: subview))`") } @@ -387,9 +387,9 @@ open class View: NSObject { /// - parameter subview: The subview to move to the front. public func bringToFront(_ subview: T?) { if let v = subview as? UIView { - view.bringSubview(toFront: v) + view.bringSubviewToFront(v) } else if let v = subview as? View { - view.bringSubview(toFront: v.view) + view.bringSubviewToFront(v.view) } else { fatalError("Can't operate on subview of class `\(type(of: subview))`") } diff --git a/C4/UI/ViewAnimation.swift b/C4/UI/ViewAnimation.swift index 97e9586b..79c4dd4f 100644 --- a/C4/UI/ViewAnimation.swift +++ b/C4/UI/ViewAnimation.swift @@ -95,19 +95,19 @@ public class ViewAnimation: Animation { public var timingFunction: CAMediaTimingFunction { switch curve { case .linear: - return CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) + return CAMediaTimingFunction(name: .linear) case .easeOut: - return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) + return CAMediaTimingFunction(name: .easeOut) case .easeIn: - return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) + return CAMediaTimingFunction(name: .easeIn) case .easeInOut: - return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + return CAMediaTimingFunction(name: .easeInEaseOut) } } ///Options for animating views using block objects. - public var options: UIViewAnimationOptions { - var options: UIViewAnimationOptions = [UIViewAnimationOptions.beginFromCurrentState] + public var options: UIView.AnimationOptions { + var options: UIView.AnimationOptions = [.beginFromCurrentState] switch curve { case .linear: options = [options, .curveLinear]