From d8409c12acd36d5e0251b8d0bc88f56f686a46f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFs=20Di=20Qual?= Date: Sun, 10 Jul 2016 18:31:26 -0700 Subject: [PATCH 01/34] Convert code base to swift 3.0 (Xcode 8.0 beta 2) --- Sources/SwiftyTimer.swift | 50 +++++++++---------- SwiftyTimer.xcodeproj/project.pbxproj | 9 +++- .../xcschemes/SwiftyTimer OS X.xcscheme | 5 +- .../xcschemes/SwiftyTimer tvOS.xcscheme | 5 +- .../xcschemes/SwiftyTimer watchOS.xcscheme | 5 +- .../xcschemes/SwiftyTimer.xcscheme | 2 +- .../project.pbxproj | 9 +++- .../xcschemes/SwiftyTimerTests.xcscheme | 8 ++- SwiftyTimerTests/SwiftyTimerTests/Info.plist | 2 +- SwiftyTimerTests/SwiftyTimerTests/main.swift | 34 ++++++------- 10 files changed, 69 insertions(+), 60 deletions(-) diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index eb76d3e..213c768 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -24,22 +24,22 @@ import Foundation -extension NSTimer { +extension Timer { // MARK: Schedule timers /// Create and schedule a timer that will call `block` once after the specified time. - public class func after(interval: NSTimeInterval, _ block: () -> Void) -> NSTimer { - let timer = NSTimer.new(after: interval, block) + public class func after(_ interval: TimeInterval, _ block: () -> Void) -> Timer { + let timer = Timer.new(after: interval, block) timer.start() return timer } /// Create and schedule a timer that will call `block` repeatedly in specified time intervals. - public class func every(interval: NSTimeInterval, _ block: () -> Void) -> NSTimer { - let timer = NSTimer.new(every: interval, block) + public class func every(_ interval: TimeInterval, _ block: () -> Void) -> Timer { + let timer = Timer.new(every: interval, block) timer.start() return timer } @@ -47,8 +47,8 @@ extension NSTimer { /// Create and schedule a timer that will call `block` repeatedly in specified time intervals. /// (This variant also passes the timer instance to the block) - @nonobjc public class func every(interval: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer { - let timer = NSTimer.new(every: interval, block) + @nonobjc public class func every(_ interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { + let timer = Timer.new(every: interval, block) timer.start() return timer } @@ -61,7 +61,7 @@ extension NSTimer { /// Use `NSTimer.after` to create and schedule a timer in one step. /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) - public class func new(after interval: NSTimeInterval, _ block: () -> Void) -> NSTimer { + public class func new(after interval: TimeInterval, _ block: () -> Void) -> Timer { return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0) { _ in block() } @@ -73,7 +73,7 @@ extension NSTimer { /// Use `NSTimer.every` to create and schedule a timer in one step. /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) - public class func new(every interval: NSTimeInterval, _ block: () -> Void) -> NSTimer { + public class func new(every interval: TimeInterval, _ block: () -> Void) -> Timer { return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in block() } @@ -86,8 +86,8 @@ extension NSTimer { /// Use `NSTimer.every` to create and schedule a timer in one step. /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) - @nonobjc public class func new(every interval: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer { - var timer: NSTimer! + @nonobjc public class func new(every interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { + var timer: Timer! timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in block(timer) } @@ -101,11 +101,11 @@ extension NSTimer { /// By default, the timer is scheduled on the current run loop for the default mode. /// Specify `runLoop` or `modes` to override these defaults. - public func start(runLoop runLoop: NSRunLoop = NSRunLoop.currentRunLoop(), modes: String...) { - let modes = modes.isEmpty ? [NSDefaultRunLoopMode] : modes + public func start(runLoop: RunLoop = RunLoop.current, modes: RunLoopMode...) { + let modes = modes.isEmpty ? [RunLoopMode.defaultRunLoopMode] : modes for mode in modes { - runLoop.addTimer(self, forMode: mode) + runLoop.add(self, forMode: mode) } } } @@ -113,19 +113,19 @@ extension NSTimer { // MARK: - Time extensions extension Double { - public var millisecond: NSTimeInterval { return self / 1000 } - public var milliseconds: NSTimeInterval { return self / 1000 } - public var ms: NSTimeInterval { return self / 1000 } + public var millisecond: TimeInterval { return self / 1000 } + public var milliseconds: TimeInterval { return self / 1000 } + public var ms: TimeInterval { return self / 1000 } - public var second: NSTimeInterval { return self } - public var seconds: NSTimeInterval { return self } + public var second: TimeInterval { return self } + public var seconds: TimeInterval { return self } - public var minute: NSTimeInterval { return self * 60 } - public var minutes: NSTimeInterval { return self * 60 } + public var minute: TimeInterval { return self * 60 } + public var minutes: TimeInterval { return self * 60 } - public var hour: NSTimeInterval { return self * 3600 } - public var hours: NSTimeInterval { return self * 3600 } + public var hour: TimeInterval { return self * 3600 } + public var hours: TimeInterval { return self * 3600 } - public var day: NSTimeInterval { return self * 3600 * 24 } - public var days: NSTimeInterval { return self * 3600 * 24 } + public var day: TimeInterval { return self * 3600 * 24 } + public var days: TimeInterval { return self * 3600 * 24 } } diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index a04be9a..0c723c9 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -205,11 +205,12 @@ 3E721AB21BF7255C008AF027 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0710; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Radosław Pietruszewski"; TargetAttributes = { 3E721ABA1BF7255D008AF027 = { CreatedOnToolsVersion = 7.1; + LastSwiftMigration = 0800; }; 6E7E40891C84B1A20030CEBB = { CreatedOnToolsVersion = 7.2; @@ -417,6 +418,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -436,6 +438,8 @@ PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -480,6 +484,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -518,6 +523,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -558,6 +564,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; diff --git a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme index cb1d60a..fd51c27 100644 --- a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme +++ b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme @@ -1,6 +1,6 @@ + buildForAnalyzing = "YES"> + buildForAnalyzing = "YES"> + buildForAnalyzing = "YES"> + buildForAnalyzing = "YES"> + buildForAnalyzing = "YES"> CFBundleIconFile CFBundleIdentifier - radex.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/SwiftyTimerTests/SwiftyTimerTests/main.swift b/SwiftyTimerTests/SwiftyTimerTests/main.swift index ff89ed1..9963c43 100644 --- a/SwiftyTimerTests/SwiftyTimerTests/main.swift +++ b/SwiftyTimerTests/SwiftyTimerTests/main.swift @@ -1,9 +1,9 @@ import Cocoa -let app = NSApplication.sharedApplication() +let app = NSApplication.shared() class AppDelegate: NSObject, NSApplicationDelegate { - func applicationDidFinishLaunching(aNotification: NSNotification) { + func applicationDidFinishLaunching(_ aNotification: Notification) { test() } @@ -23,18 +23,18 @@ class AppDelegate: NSObject, NSApplicationDelegate { func test2() { var fired = false - NSTimer.after(0.1.seconds) { + Timer.after(0.1.seconds) { assert(!fired) fired = true self.test3() } } - var timer1: NSTimer! + var timer1: Timer! func test3() { var fired = false - timer1 = NSTimer.every(0.1.seconds) { + timer1 = Timer.every(0.1.seconds) { if fired { self.test4() self.timer1.invalidate() @@ -44,21 +44,21 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } - let timer2 = NSTimer.new(after: 0.1.seconds) { fatalError() } - let timer3 = NSTimer.new(every: 0.1.seconds) { fatalError() } + let timer2 = Timer.new(after: 0.1.seconds) { fatalError() } + let timer3 = Timer.new(every: 0.1.seconds) { fatalError() } func test4() { - let timer = NSTimer.new(after: 0.1.seconds) { + let timer = Timer.new(after: 0.1.seconds) { self.test5() } - NSRunLoop.currentRunLoop().addTimer(timer, forMode: NSDefaultRunLoopMode) + RunLoop.current.add(timer, forMode: RunLoopMode.defaultRunLoopMode) } - var timer4: NSTimer! + var timer4: Timer! func test5() { var fired = false - timer4 = NSTimer.new(every: 0.1.seconds) { + timer4 = Timer.new(every: 0.1.seconds) { if fired { self.timer4.invalidate() self.test6() @@ -70,20 +70,20 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func test6() { - let timer = NSTimer.new(after: 0.1.seconds) { + let timer = Timer.new(after: 0.1.seconds) { self.test7() } - timer.start(runLoop: NSRunLoop.currentRunLoop(), modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode) + timer.start(runLoop: RunLoop.current, modes: RunLoopMode.defaultRunLoopMode, RunLoopMode(NSEventTrackingRunLoopMode)) } func test7() { - NSTimer.after(0.1.seconds, test8) + Timer.after(0.1.seconds, test8) } func test8() { var fires = 0 - let timer = NSTimer.new(every: 0.1.seconds) { (timer: NSTimer) in + let timer = Timer.new(every: 0.1.seconds) { (timer: Timer) in guard fires <= 1 else { fatalError("should be invalidated") } defer { fires += 1 } @@ -97,7 +97,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { func test9() { var fires = 0 - NSTimer.every(0.1.seconds) { (timer: NSTimer) in + Timer.every(0.1.seconds) { (timer: Timer) in guard fires <= 1 else { fatalError("should be invalidated") } defer { fires += 1 } @@ -116,4 +116,4 @@ class AppDelegate: NSObject, NSApplicationDelegate { let delegate = AppDelegate() app.delegate = delegate -app.run() \ No newline at end of file +app.run() From f4b41ff3674994d8930e7ef2b16e0c26e91d3990 Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Sat, 23 Jul 2016 08:49:30 +0200 Subject: [PATCH 02/34] Mark Swift 2.3 compatibility --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 03f2c2e..6488962 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![CI Status](https://api.travis-ci.org/radex/SwiftyTimer.svg?branch=master)](https://travis-ci.org/radex/SwiftyTimer) [![CocoaPods](http://img.shields.io/cocoapods/v/SwiftyTimer.svg)](https://cocoapods.org/pods/SwiftyTimer) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage) -![Swift version](https://img.shields.io/badge/swift-2.2-orange.svg) +![Swift version](https://img.shields.io/badge/swift-2.2,%202.3-orange.svg) #### Modern Swifty API for `NSTimer` ###### SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It's time to get rid of Objective-C cruft. From 13777bb16ea197e0bbbdc269dfaa1216951ad380 Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Sat, 23 Jul 2016 08:50:52 +0200 Subject: [PATCH 03/34] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6488962..0788402 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![CI Status](https://api.travis-ci.org/radex/SwiftyTimer.svg?branch=master)](https://travis-ci.org/radex/SwiftyTimer) [![CocoaPods](http://img.shields.io/cocoapods/v/SwiftyTimer.svg)](https://cocoapods.org/pods/SwiftyTimer) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage) -![Swift version](https://img.shields.io/badge/swift-2.2,%202.3-orange.svg) +![Swift version](https://img.shields.io/badge/swift-2.2%20|%202.3-orange.svg) #### Modern Swifty API for `NSTimer` ###### SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It's time to get rid of Objective-C cruft. From 608e3c6e0a209edc4b08db5ad12e5697ddbed7e2 Mon Sep 17 00:00:00 2001 From: radex Date: Sat, 23 Jul 2016 12:40:01 +0200 Subject: [PATCH 04/34] Fix build settings --- SwiftyTimer.xcodeproj/project.pbxproj | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 0c723c9..0b50010 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -353,6 +353,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -394,6 +395,8 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -417,8 +420,6 @@ PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -438,8 +439,6 @@ PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; }; name = Release; }; @@ -484,7 +483,6 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -523,7 +521,6 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -564,7 +561,6 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; From 51dbb758cd88ac3ead86170793ba92820aef9de5 Mon Sep 17 00:00:00 2001 From: radex Date: Sat, 23 Jul 2016 12:42:18 +0200 Subject: [PATCH 05/34] Mark `Timer.after`, `Timer.every` as @discardableResult --- Sources/SwiftyTimer.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index 213c768..debd896 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -30,6 +30,7 @@ extension Timer { /// Create and schedule a timer that will call `block` once after the specified time. + @discardableResult public class func after(_ interval: TimeInterval, _ block: () -> Void) -> Timer { let timer = Timer.new(after: interval, block) timer.start() @@ -38,6 +39,7 @@ extension Timer { /// Create and schedule a timer that will call `block` repeatedly in specified time intervals. + @discardableResult public class func every(_ interval: TimeInterval, _ block: () -> Void) -> Timer { let timer = Timer.new(every: interval, block) timer.start() @@ -47,7 +49,8 @@ extension Timer { /// Create and schedule a timer that will call `block` repeatedly in specified time intervals. /// (This variant also passes the timer instance to the block) - @nonobjc public class func every(_ interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { + @nonobjc @discardableResult + public class func every(_ interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { let timer = Timer.new(every: interval, block) timer.start() return timer From 9f914656760a1b90908b66b7ed41fb97bfdfc137 Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Sat, 23 Jul 2016 12:45:33 +0200 Subject: [PATCH 06/34] Mention the Swift 3 branch --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0788402..c92224c 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ NSTimer.every(5.seconds) { (timer: NSTimer) in ## Installation +**For Swift 3 compatibility, check out [the `swift3` branch](https://github.com/radex/SwiftyTimer/tree/swift3)** + If you're using CocoaPods, just add this line to your Podfile: ```ruby From 6ac744f5efffb322e8a47bd78420eccd127cfaaf Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Sat, 23 Jul 2016 12:53:04 +0200 Subject: [PATCH 07/34] Update README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0788402..c12ed66 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![CI Status](https://api.travis-ci.org/radex/SwiftyTimer.svg?branch=master)](https://travis-ci.org/radex/SwiftyTimer) [![CocoaPods](http://img.shields.io/cocoapods/v/SwiftyTimer.svg)](https://cocoapods.org/pods/SwiftyTimer) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage) -![Swift version](https://img.shields.io/badge/swift-2.2%20|%202.3-orange.svg) +![Swift version](https://img.shields.io/badge/swift-3.0-orange.svg) #### Modern Swifty API for `NSTimer` ###### SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It's time to get rid of Objective-C cruft. @@ -13,14 +13,14 @@ Read [Swifty APIs: NSTimer](http://radex.io/swift/nstimer/) for more information ## Usage -You can easily schedule repeating and non-repeating timers (repeats and delays) using `NSTimer.every` and `NSTimer.after`: +You can easily schedule repeating and non-repeating timers (repeats and delays) using `Timer.every` and `Timer.after`: ```swift -NSTimer.every(0.7.seconds) { +Timer.every(0.7.seconds) { statusItem.blink() } -NSTimer.after(1.minute) { +Timer.after(1.minute) { println("Are you still here?") } ``` @@ -40,7 +40,7 @@ You can specify time intervals with these intuitive helpers: You can pass method references instead of closures: ```swift -NSTimer.every(30.seconds, align) +Timer.every(30.seconds, align) ``` ### Manual scheduling @@ -48,7 +48,7 @@ NSTimer.every(30.seconds, align) If you want to make a timer object without scheduling, use `new(after:)` and `new(every:)`: ```swift -let timer = NSTimer.new(every: 1.second) { +let timer = Timer.new(every: 1.second) { println(self.status) } ``` @@ -59,15 +59,15 @@ Call `start()` to schedule timers created using `new`. You can optionally pass t ```swift timer.start() -timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode) +timer.start(modes: .defaultRunLoopMode, RunLoopMode(NSEventTrackingRunLoopMode)) // Ugly, yes: rdar://27509030 ``` ### Invalidation -If you want to invalidate a repeating timer on some condition, you can take an `NSTimer` argument in the closure you pass in: +If you want to invalidate a repeating timer on some condition, you can take a `Timer` argument in the closure you pass in: ```swift -NSTimer.every(5.seconds) { (timer: NSTimer) in +Timer.every(5.seconds) { (timer: Timer) in // do something if finished { From c2250c982b7072ac0ac51ca463c0267fbb9a3872 Mon Sep 17 00:00:00 2001 From: radex Date: Sat, 23 Jul 2016 12:53:47 +0200 Subject: [PATCH 08/34] Use implicit member expressions --- SwiftyTimerTests/SwiftyTimerTests/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftyTimerTests/SwiftyTimerTests/main.swift b/SwiftyTimerTests/SwiftyTimerTests/main.swift index 9963c43..f808c8c 100644 --- a/SwiftyTimerTests/SwiftyTimerTests/main.swift +++ b/SwiftyTimerTests/SwiftyTimerTests/main.swift @@ -74,7 +74,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.test7() } - timer.start(runLoop: RunLoop.current, modes: RunLoopMode.defaultRunLoopMode, RunLoopMode(NSEventTrackingRunLoopMode)) + timer.start(runLoop: .current, modes: .defaultRunLoopMode, RunLoopMode(NSEventTrackingRunLoopMode)) } func test7() { From 3c8361f8c89661439d78a2bf47e76d08c5640f3a Mon Sep 17 00:00:00 2001 From: radex Date: Sat, 23 Jul 2016 12:57:19 +0200 Subject: [PATCH 09/34] Update Readme and Changelog --- CHANGELOG.md | 4 ++++ README.md | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0dfd64..9a82568 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### swift3 + +- Updated for Swift 3 and Xcode 8 compatibility #28 @ldiqual + ### 1.4.0 (2016-04-10) - Add a variant of `every` and `new(every:)` that takes a closure with `NSTimer` passed in diff --git a/README.md b/README.md index c12ed66..0a0800c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SwiftyTimer +# SwiftyTimer (Swift 3) ![Platforms](https://img.shields.io/badge/platforms-ios%20%7C%20osx%20%7C%20watchos%20%7C%20tvos-lightgrey.svg) [![CI Status](https://api.travis-ci.org/radex/SwiftyTimer.svg?branch=master)](https://travis-ci.org/radex/SwiftyTimer) @@ -53,7 +53,7 @@ let timer = Timer.new(every: 1.second) { } ``` -(This should be defined as an initializer, but [a bug in Swift](http://www.openradar.me/18720947) prevents this) +(This should be defined as an initializer, but [a bug in Foundation](http://www.openradar.me/18720947) prevents this) Call `start()` to schedule timers created using `new`. You can optionally pass the run loop and run loop modes: @@ -81,7 +81,7 @@ Timer.every(5.seconds) { (timer: Timer) in If you're using CocoaPods, just add this line to your Podfile: ```ruby -pod 'SwiftyTimer' +pod 'SwiftyTimer', git: 'https://github.com/radex/SwiftyTimer.git', branch: 'swift3' ``` Install by running this command in your terminal: @@ -101,7 +101,7 @@ import SwiftyTimer Just add to your Cartfile: ```ruby -github "radex/SwiftyTimer" +github "radex/SwiftyTimer" "swift3" ``` #### Manually From eb4606f80b4b800b31c907517dc53eaafb9079d0 Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Sat, 23 Jul 2016 13:00:28 +0200 Subject: [PATCH 10/34] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8c6dbd5..e6fc502 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: objective-c cache: cocoapods rvm: 2.2.2 -osx_image: xcode7.2 +osx_image: xcode8 before_install: - gem install cocoapods @@ -20,4 +20,4 @@ script: - set -o pipefail && xctool archive -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests -- pod lib lint \ No newline at end of file +- pod lib lint From aa922ce02f3d6150996d89e39bf985fd0522db04 Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Sat, 23 Jul 2016 13:32:23 +0200 Subject: [PATCH 11/34] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c92224c..fda96ee 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,8 @@ NSTimer.every(5.seconds) { (timer: NSTimer) in **For Swift 3 compatibility, check out [the `swift3` branch](https://github.com/radex/SwiftyTimer/tree/swift3)** +#### CocoaPods + If you're using CocoaPods, just add this line to your Podfile: ```ruby From e0f696b7b22665b0f9ff1105d40833ec50710828 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 3 Aug 2016 08:46:25 +0200 Subject: [PATCH 12/34] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 9e0e45b..e97e934 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Radosław Pietruszewski +Copyright (c) 2015-2016 Radosław Pietruszewski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d1e72bb2eedbf7caa1030fc3ed5f9c322ecff8d3 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 3 Aug 2016 08:47:30 +0200 Subject: [PATCH 13/34] Set SWIFT_VERSION = 2.3 --- SwiftyTimer.xcodeproj/project.pbxproj | 2 ++ SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 4 insertions(+) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index a04be9a..748c3f2 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -352,6 +352,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 2.3; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -393,6 +394,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_VERSION = 2.3; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj index a49a698..fd6d29e 100644 --- a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -179,6 +179,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 2.3; }; name = Debug; }; @@ -215,6 +216,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; + SWIFT_VERSION = 2.3; }; name = Release; }; From df52a708f70a1762cd812f9ba77be4125357bb0a Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 3 Aug 2016 08:49:02 +0200 Subject: [PATCH 14/34] Update CHANGELOG / Bump to 1.4.1 --- CHANGELOG.md | 4 ++++ SwiftyTimer.podspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0dfd64..2707b08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.4.1 (2016-08-03) + +- Add support for Xcode 8 (Swift 2.3) for Carthage users + ### 1.4.0 (2016-04-10) - Add a variant of `every` and `new(every:)` that takes a closure with `NSTimer` passed in diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index 6c58984..c39b34f 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '1.4.0' + s.version = '1.4.1' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' s.homepage = 'https://github.com/radex/SwiftyTimer' From 7322a18d083d41132afb3be07e4885f800972600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFs=20Di=20Qual?= Date: Fri, 19 Aug 2016 21:50:37 +0200 Subject: [PATCH 15/34] Migrate to Xcode 8 beta 6 --- Sources/SwiftyTimer.swift | 12 ++++++------ SwiftyTimerTests/SwiftyTimerTests/main.swift | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index debd896..86a3f77 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -31,7 +31,7 @@ extension Timer { /// Create and schedule a timer that will call `block` once after the specified time. @discardableResult - public class func after(_ interval: TimeInterval, _ block: () -> Void) -> Timer { + public class func after(_ interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { let timer = Timer.new(after: interval, block) timer.start() return timer @@ -40,7 +40,7 @@ extension Timer { /// Create and schedule a timer that will call `block` repeatedly in specified time intervals. @discardableResult - public class func every(_ interval: TimeInterval, _ block: () -> Void) -> Timer { + public class func every(_ interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { let timer = Timer.new(every: interval, block) timer.start() return timer @@ -50,7 +50,7 @@ extension Timer { /// (This variant also passes the timer instance to the block) @nonobjc @discardableResult - public class func every(_ interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { + public class func every(_ interval: TimeInterval, _ block: @escaping (Timer) -> Void) -> Timer { let timer = Timer.new(every: interval, block) timer.start() return timer @@ -64,7 +64,7 @@ extension Timer { /// Use `NSTimer.after` to create and schedule a timer in one step. /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) - public class func new(after interval: TimeInterval, _ block: () -> Void) -> Timer { + public class func new(after interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0) { _ in block() } @@ -76,7 +76,7 @@ extension Timer { /// Use `NSTimer.every` to create and schedule a timer in one step. /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) - public class func new(every interval: TimeInterval, _ block: () -> Void) -> Timer { + public class func new(every interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in block() } @@ -89,7 +89,7 @@ extension Timer { /// Use `NSTimer.every` to create and schedule a timer in one step. /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) - @nonobjc public class func new(every interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { + @nonobjc public class func new(every interval: TimeInterval, _ block: @escaping (Timer) -> Void) -> Timer { var timer: Timer! timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in block(timer) diff --git a/SwiftyTimerTests/SwiftyTimerTests/main.swift b/SwiftyTimerTests/SwiftyTimerTests/main.swift index f808c8c..e67630f 100644 --- a/SwiftyTimerTests/SwiftyTimerTests/main.swift +++ b/SwiftyTimerTests/SwiftyTimerTests/main.swift @@ -74,7 +74,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.test7() } - timer.start(runLoop: .current, modes: .defaultRunLoopMode, RunLoopMode(NSEventTrackingRunLoopMode)) + timer.start(runLoop: .current, modes: .defaultRunLoopMode, .eventTrackingRunLoopMode) } func test7() { From 9bcd1f089ed7d99a29521e11d76152c4184f4e07 Mon Sep 17 00:00:00 2001 From: radex Date: Thu, 15 Sep 2016 13:07:35 +0200 Subject: [PATCH 16/34] Clean up a little --- Sources/SwiftyTimer.swift | 4 ++-- SwiftyTimerTests/SwiftyTimerTests/main.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index 86a3f77..519e720 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -104,8 +104,8 @@ extension Timer { /// By default, the timer is scheduled on the current run loop for the default mode. /// Specify `runLoop` or `modes` to override these defaults. - public func start(runLoop: RunLoop = RunLoop.current, modes: RunLoopMode...) { - let modes = modes.isEmpty ? [RunLoopMode.defaultRunLoopMode] : modes + public func start(runLoop: RunLoop = .current, modes: RunLoopMode...) { + let modes = modes.isEmpty ? [.defaultRunLoopMode] : modes for mode in modes { runLoop.add(self, forMode: mode) diff --git a/SwiftyTimerTests/SwiftyTimerTests/main.swift b/SwiftyTimerTests/SwiftyTimerTests/main.swift index e67630f..c3bd838 100644 --- a/SwiftyTimerTests/SwiftyTimerTests/main.swift +++ b/SwiftyTimerTests/SwiftyTimerTests/main.swift @@ -51,7 +51,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let timer = Timer.new(after: 0.1.seconds) { self.test5() } - RunLoop.current.add(timer, forMode: RunLoopMode.defaultRunLoopMode) + RunLoop.current.add(timer, forMode: .defaultRunLoopMode) } var timer4: Timer! From 8cb3860bfef05fc86860b73398a02b96ae0b789b Mon Sep 17 00:00:00 2001 From: radex Date: Thu, 15 Sep 2016 13:09:16 +0200 Subject: [PATCH 17/34] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a0800c..cf2472d 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Call `start()` to schedule timers created using `new`. You can optionally pass t ```swift timer.start() -timer.start(modes: .defaultRunLoopMode, RunLoopMode(NSEventTrackingRunLoopMode)) // Ugly, yes: rdar://27509030 +timer.start(modes: .defaultRunLoopMode, .eventTrackingRunLoopMode) ``` ### Invalidation From b8dcd791d9a33da24cd107e4588f363eb7f54fde Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 23 Sep 2016 18:35:06 +0200 Subject: [PATCH 18/34] Add .swift-version --- .swift-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .swift-version diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..9f55b2c --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 From 9f6225a05c96f099e1ea710af66f7e318e41327f Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 23 Sep 2016 18:38:38 +0200 Subject: [PATCH 19/34] Set SWIFT_VERSION = 3.0 --- SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj index 869a2cb..b9b3815 100644 --- a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -181,6 +181,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -217,6 +218,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; + SWIFT_VERSION = 3.0; }; name = Release; }; From 4e41474ba63f049fd67875b30fb4151db7983f43 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 23 Sep 2016 18:39:22 +0200 Subject: [PATCH 20/34] Update Xcode projects to recommended settings --- SwiftyTimer.xcodeproj/project.pbxproj | 14 ++++++++++++-- .../SwiftyTimerTests.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 0b50010..70f8d1b 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -323,8 +323,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -373,8 +375,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -409,6 +413,7 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -428,6 +433,7 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -446,7 +452,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -468,7 +474,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -490,6 +496,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -510,6 +517,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -530,6 +538,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -550,6 +559,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj index b9b3815..21a12ee 100644 --- a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -152,8 +152,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; @@ -198,8 +200,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; From 3e50c53759cf9c338142e0772b344d0bc77fe558 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 23 Sep 2016 18:39:59 +0200 Subject: [PATCH 21/34] Bump to 2.0.0 / Update Changelog --- CHANGELOG.md | 6 +++++- SwiftyTimer.podspec | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a82568..c6c8219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -### swift3 +### 2.0.0 (2016-09-23) + +This is the Swift 3 update version. + +It contains no major changes in the library itself, however it does change some APIs because of Swift 3 requirements. - Updated for Swift 3 and Xcode 8 compatibility #28 @ldiqual diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index 6c58984..f68ac4e 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '1.4.0' + s.version = '2.0.0' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' s.homepage = 'https://github.com/radex/SwiftyTimer' From a51e1b0a10787a42e45b14553f3803f68c790291 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 23 Sep 2016 18:43:51 +0200 Subject: [PATCH 22/34] Update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index feaddbe..9909d53 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SwiftyTimer (Swift 3) +# SwiftyTimer ![Platforms](https://img.shields.io/badge/platforms-ios%20%7C%20osx%20%7C%20watchos%20%7C%20tvos-lightgrey.svg) [![CI Status](https://api.travis-ci.org/radex/SwiftyTimer.svg?branch=master)](https://travis-ci.org/radex/SwiftyTimer) @@ -78,14 +78,14 @@ Timer.every(5.seconds) { (timer: Timer) in ## Installation -**For Swift 3 compatibility, check out [the `swift3` branch](https://github.com/radex/SwiftyTimer/tree/swift3)** +**Note:** If you're running Swift 2, use [SwiftyTimer v1.4.1](https://github.com/radex/SwiftyTimer/tree/1.4.1) #### CocoaPods If you're using CocoaPods, just add this line to your Podfile: ```ruby -pod 'SwiftyTimer', git: 'https://github.com/radex/SwiftyTimer.git', branch: 'swift3' +pod 'SwiftyTimer' ``` Install by running this command in your terminal: @@ -105,7 +105,7 @@ import SwiftyTimer Just add to your Cartfile: ```ruby -github "radex/SwiftyTimer" "swift3" +github "radex/SwiftyTimer" ``` #### Manually From f200b3a5f35e2c66402f30f8d5a9cc33c2c65614 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 23 Sep 2016 19:03:16 +0200 Subject: [PATCH 23/34] Update .travis.yml --- .travis.yml | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index e6fc502..dafa274 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,21 +3,26 @@ cache: cocoapods rvm: 2.2.2 osx_image: xcode8 +env: + global: + - LC_CTYPE=en_US.UTF-8 + - LANG=en_US.UTF-8 + - PROJECT=SwiftyTimer.xcodeproj + before_install: -- gem install cocoapods -- gem install xcpretty + - gem install cocoapods + - gem install xcpretty script: -- set -o pipefail && xctool build -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer' -destination 'name=iPhone 6,OS=9.2' ONLY_ACTIVE_ARCH=NO | xcpretty -- set -o pipefail && xctool build -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer tvOS' -sdk iphonesimulator -destination 'name=Apple TV 1080p' ONLY_ACTIVE_ARCH=NO | xcpretty -- set -o pipefail && xctool build -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO | xcpretty -- set -o pipefail && xctool build -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer OS X' ONLY_ACTIVE_ARCH=NO | xcpretty - -# - set -o pipefail && xctool test -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer' -sdk iphonesimulator -destination 'name=iPhone 6,OS=9.2' ONLY_ACTIVE_ARCH=NO | xcpretty -# - set -o pipefail && xctool test -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer tvOS' -sdk iphonesimulator -destination 'name=Apple TV 1080p' ONLY_ACTIVE_ARCH=NO | xcpretty -# - set -o pipefail && xctool test -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO | xcpretty -# - set -o pipefail && xctool test -project SwiftyTimer.xcodeproj -scheme 'SwiftyTimer Mac' ONLY_ACTIVE_ARCH=NO | xcpretty - -- set -o pipefail && xctool archive -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests - -- pod lib lint + - set -o pipefail + - xcodebuild -version + - xcodebuild -showsdks + + - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer' -destination 'name=iPhone 6,OS=10.0' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty + - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer tvOS' -sdk appletvsimulator10.0 -destination 'name=Apple TV 1080p' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty + - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty + - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer OS X' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty + + - xctool archive -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests + + - pod lib lint From 408815031d26580701b07ac5e8b83ec7171c39a4 Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Fri, 23 Sep 2016 19:15:57 +0200 Subject: [PATCH 24/34] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dafa274..c3b2c29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - PROJECT=SwiftyTimer.xcodeproj before_install: - - gem install cocoapods + - gem install cocoapods -v 1.1.0.rc2 # remove -v after it ships - gem install xcpretty script: @@ -23,6 +23,6 @@ script: - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer OS X' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - - xctool archive -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests + - pod _1.1.0.rc2_ lib lint - - pod lib lint + - xcodebuild -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' archive && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests From daad3576a64e934c4fcdfc33bb30f87ed1441777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Cant=C3=A9rot?= Date: Tue, 3 Jan 2017 02:34:37 +0100 Subject: [PATCH 25/34] Fix Package.swift not building --- Package.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 22d6634..507af30 100644 --- a/Package.swift +++ b/Package.swift @@ -1,6 +1,8 @@ import PackageDescription let package = Package( - exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h", "SwiftyTimerTests"], - dependencies: [] + name: "SwiftyTimer", + dependencies: [], + exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h", "SwiftyTimerTests"] + ) \ No newline at end of file From f26d3c743d6a116babf48204735c557fa3fb6831 Mon Sep 17 00:00:00 2001 From: Andrew Sowers Date: Mon, 8 Oct 2018 21:45:44 -0400 Subject: [PATCH 26/34] building on Swift 4.2 --- Sources/SwiftyTimer.swift | 4 +-- SwiftyTimer.xcodeproj/project.pbxproj | 26 ++++++++++++++++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ .../xcschemes/SwiftyTimer OS X.xcscheme | 2 +- .../xcschemes/SwiftyTimer tvOS.xcscheme | 2 +- .../xcschemes/SwiftyTimer watchOS.xcscheme | 2 +- .../xcschemes/SwiftyTimer.xcscheme | 2 +- 7 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 SwiftyTimer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index 519e720..bbc78f3 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -104,8 +104,8 @@ extension Timer { /// By default, the timer is scheduled on the current run loop for the default mode. /// Specify `runLoop` or `modes` to override these defaults. - public func start(runLoop: RunLoop = .current, modes: RunLoopMode...) { - let modes = modes.isEmpty ? [.defaultRunLoopMode] : modes + public func start(runLoop: RunLoop = .current, modes: RunLoop.Mode...) { + let modes = modes.isEmpty ? [.default] : modes for mode in modes { runLoop.add(self, forMode: mode) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 70f8d1b..283253b 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -205,7 +205,7 @@ 3E721AB21BF7255C008AF027 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "Radosław Pietruszewski"; TargetAttributes = { 3E721ABA1BF7255D008AF027 = { @@ -318,14 +318,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; @@ -370,14 +378,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; @@ -425,6 +441,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -445,6 +462,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -467,6 +485,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -489,6 +508,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -508,6 +528,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -529,6 +550,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -550,6 +572,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -571,6 +594,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; diff --git a/SwiftyTimer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftyTimer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftyTimer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme index fd51c27..ada9aa8 100644 --- a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme +++ b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme @@ -1,6 +1,6 @@ Date: Mon, 8 Oct 2018 21:57:07 -0400 Subject: [PATCH 27/34] updated travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c3b2c29..40e68bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: objective-c cache: cocoapods rvm: 2.2.2 -osx_image: xcode8 +osx_image: xcode10 env: global: @@ -10,7 +10,7 @@ env: - PROJECT=SwiftyTimer.xcodeproj before_install: - - gem install cocoapods -v 1.1.0.rc2 # remove -v after it ships + - gem install cocoapods - gem install xcpretty script: From fd022636346b8cafe68c719502c18c3a4f8c8f20 Mon Sep 17 00:00:00 2001 From: Andrew Sowers Date: Mon, 8 Oct 2018 22:04:14 -0400 Subject: [PATCH 28/34] updated ruby version, specified Swift 4.2 in Project in addition to targets --- .travis.yml | 2 +- SwiftyTimer.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 40e68bd..835dc8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: objective-c cache: cocoapods -rvm: 2.2.2 +rvm: 2.4.2 osx_image: xcode10 env: diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 283253b..e1f7577 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -363,7 +363,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -416,7 +416,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; From 7515b3b68a8b183d0fa25b34e3c7221cec556103 Mon Sep 17 00:00:00 2001 From: Andrew Sowers Date: Mon, 8 Oct 2018 22:10:33 -0400 Subject: [PATCH 29/34] updated tests to Swift 4.2 --- .../project.pbxproj | 26 +++++++++++++++---- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ .../xcschemes/SwiftyTimerTests.xcscheme | 2 +- SwiftyTimerTests/SwiftyTimerTests/main.swift | 6 ++--- 4 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj index 21a12ee..854241d 100644 --- a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -90,7 +90,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1000; TargetAttributes = { 6EE9C1521B00BB5B00D6B91C = { CreatedOnToolsVersion = 6.4; @@ -147,14 +147,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; @@ -183,7 +191,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -195,14 +203,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; @@ -222,7 +238,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -235,7 +251,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "radex.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -249,7 +265,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "radex.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme index 1623a50..e172c40 100644 --- a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme @@ -1,6 +1,6 @@ Date: Mon, 8 Oct 2018 22:25:57 -0400 Subject: [PATCH 30/34] remove cocoapods from cache --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 835dc8a..e8da81f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: objective-c -cache: cocoapods rvm: 2.4.2 osx_image: xcode10 @@ -23,6 +22,6 @@ script: - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer OS X' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - - pod _1.1.0.rc2_ lib lint + - pod lib lint - xcodebuild -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' archive && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests From 7618afc2ed319ce0fb833dc42602ba229eab290b Mon Sep 17 00:00:00 2001 From: Andrew Sowers Date: Mon, 8 Oct 2018 22:59:56 -0400 Subject: [PATCH 31/34] updated Swift version file, bumped podspec to 2.1.0, removed swift lint from travis test due to some issue with Xcode 10 and cocoapods --- .swift-version | 2 +- .travis.yml | 2 -- SwiftyTimer.podspec | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.swift-version b/.swift-version index 9f55b2c..bf77d54 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.2 diff --git a/.travis.yml b/.travis.yml index e8da81f..3a5496f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,4 @@ script: - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer OS X' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - - pod lib lint - - xcodebuild -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' archive && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index f68ac4e..bf9c24a 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '2.0.0' + s.version = '2.1.0' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' s.homepage = 'https://github.com/radex/SwiftyTimer' @@ -14,4 +14,4 @@ Pod::Spec.new do |s| s.watchos.deployment_target = '2.0' s.source_files = 'Sources/*.swift' -end \ No newline at end of file +end From 20536d7e25fb55db428f9bd2353a55ee8d3050f3 Mon Sep 17 00:00:00 2001 From: Andrew Sowers Date: Mon, 8 Oct 2018 23:06:06 -0400 Subject: [PATCH 32/34] using locatable tvOS simulator for travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a5496f..146e3ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - xcodebuild -showsdks - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer' -destination 'name=iPhone 6,OS=10.0' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer tvOS' -sdk appletvsimulator10.0 -destination 'name=Apple TV 1080p' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty + - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer tvOS' -sdk appletvsimulator12.0 -destination 'name=Apple TV 1080p' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer OS X' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty From d8db0304f7957f03d5b88a5b5e237537c5b06d7c Mon Sep 17 00:00:00 2001 From: Andrew Sowers Date: Mon, 8 Oct 2018 23:13:18 -0400 Subject: [PATCH 33/34] using proper Apple TV simulator name for tvOS 12 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 146e3ef..0930560 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - xcodebuild -showsdks - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer' -destination 'name=iPhone 6,OS=10.0' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer tvOS' -sdk appletvsimulator12.0 -destination 'name=Apple TV 1080p' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty + - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer tvOS' -sdk appletvsimulator12.0 -destination 'name=Apple TV' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer watchOS' -sdk iphonesimulator -destination 'name=Apple Watch - 42mm' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty - xcodebuild -project "$PROJECT" -scheme 'SwiftyTimer OS X' ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build | xcpretty From b12a05e877a493e8fde4fe4c1cbb54a191f417e3 Mon Sep 17 00:00:00 2001 From: Andrew Sowers Date: Sun, 14 Oct 2018 21:10:06 -0400 Subject: [PATCH 34/34] Added changelog, updated README and Podspec to reflect Swift 4.2 version --- CHANGELOG.md | 8 +++++++- README.md | 2 +- SwiftyTimer.podspec | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18fbf4d..6448adb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 2.1.0 (2018-10-14) + +This version supports Swift 4.2 without introducing changes to the library workflow. +Library source modifications include adopting new changes in the `RunLoopMode` enum introduced in Swift 4.2 +- Updated for Swift 4.2 and Xcode 10 #45 @asowers1 + ### 2.0.0 (2016-09-23) This is the Swift 3 update version. @@ -41,4 +47,4 @@ It contains no major changes in the library itself, however it does change some - Initial release - `NSTimer.after(...)` and `NSTimer.every(...)` - `NSTimer.new` -- Ruby on Rails-inspired time helpers like (5.seconds or 1.minute) \ No newline at end of file +- Ruby on Rails-inspired time helpers like (5.seconds or 1.minute) diff --git a/README.md b/README.md index 9909d53..cd25710 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![CI Status](https://api.travis-ci.org/radex/SwiftyTimer.svg?branch=master)](https://travis-ci.org/radex/SwiftyTimer) [![CocoaPods](http://img.shields.io/cocoapods/v/SwiftyTimer.svg)](https://cocoapods.org/pods/SwiftyTimer) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage) -![Swift version](https://img.shields.io/badge/swift-3.0-orange.svg) +![Swift version](https://img.shields.io/badge/swift-4.2-orange.svg) #### Modern Swifty API for `NSTimer` ###### SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It's time to get rid of Objective-C cruft. diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index bf9c24a..06db5d9 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/radex/SwiftyTimer' s.authors = { 'Radek Pietruszewski' => 'this.is@radex.io' } s.source = { git: 'https://github.com/radex/SwiftyTimer.git', tag: s.version } - + s.swift_version = '4.2' s.requires_arc = true s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.9'