diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..bf77d54 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +4.2 diff --git a/.travis.yml b/.travis.yml index 8c6dbd5..0930560 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,25 @@ language: objective-c -cache: cocoapods -rvm: 2.2.2 -osx_image: xcode7.2 +rvm: 2.4.2 +osx_image: xcode10 + +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 \ No newline at end of file + - 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 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 + + - xcodebuild -archivePath 'Tests' -project SwiftyTimerTests/SwiftyTimerTests.xcodeproj -scheme 'SwiftyTimerTests' archive && Tests.xcarchive/Products/Applications/SwiftyTimerTests.app/Contents/MacOS/SwiftyTimerTests diff --git a/CHANGELOG.md b/CHANGELOG.md index 2707b08..6448adb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +### 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. + +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 + ### 1.4.1 (2016-08-03) - Add support for Xcode 8 (Swift 2.3) for Carthage users @@ -33,4 +47,4 @@ - 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/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 diff --git a/README.md b/README.md index fda96ee..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-2.2%20|%202.3-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. @@ -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,26 +48,26 @@ 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) } ``` -(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: ```swift timer.start() -timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode) +timer.start(modes: .defaultRunLoopMode, .eventTrackingRunLoopMode) ``` ### 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 { @@ -78,7 +78,7 @@ NSTimer.every(5.seconds) { (timer: NSTimer) 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 diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index eb76d3e..bbc78f3 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -24,22 +24,24 @@ 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) + @discardableResult + public class func after(_ interval: TimeInterval, _ block: @escaping () -> 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) + @discardableResult + public class func every(_ interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { + let timer = Timer.new(every: interval, block) timer.start() return timer } @@ -47,8 +49,9 @@ 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 @discardableResult + public class func every(_ interval: TimeInterval, _ block: @escaping (Timer) -> Void) -> Timer { + let timer = Timer.new(every: interval, block) timer.start() return timer } @@ -61,7 +64,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: @escaping () -> Void) -> Timer { return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0) { _ in block() } @@ -73,7 +76,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: @escaping () -> Void) -> Timer { return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in block() } @@ -86,8 +89,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: @escaping (Timer) -> Void) -> Timer { + var timer: Timer! timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in block(timer) } @@ -101,11 +104,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 = .current, modes: RunLoop.Mode...) { + let modes = modes.isEmpty ? [.default] : modes for mode in modes { - runLoop.addTimer(self, forMode: mode) + runLoop.add(self, forMode: mode) } } } @@ -113,19 +116,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.podspec b/SwiftyTimer.podspec index c39b34f..06db5d9 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '1.4.1' + s.version = '2.1.0' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' 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' @@ -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 diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 748c3f2..e1f7577 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -205,11 +205,12 @@ 3E721AB21BF7255C008AF027 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0710; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "Radosław Pietruszewski"; TargetAttributes = { 3E721ABA1BF7255D008AF027 = { CreatedOnToolsVersion = 7.1; + LastSwiftMigration = 0800; }; 6E7E40891C84B1A20030CEBB = { CreatedOnToolsVersion = 7.2; @@ -317,13 +318,23 @@ 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -352,7 +363,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -367,13 +378,23 @@ 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -394,7 +415,8 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_VERSION = 2.3; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -407,6 +429,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; @@ -418,7 +441,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -427,6 +450,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; @@ -438,6 +462,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -445,7 +470,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; @@ -460,6 +485,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -467,7 +493,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; @@ -482,6 +508,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -489,6 +516,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; @@ -500,6 +528,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -509,6 +538,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; @@ -520,6 +550,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -529,6 +560,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; @@ -540,6 +572,7 @@ PRODUCT_NAME = SwiftyTimer; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -549,6 +582,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; @@ -560,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 cb1d60a..ada9aa8 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"> + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme index 2451e11..e172c40 100644 --- a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme @@ -1,6 +1,6 @@ + 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..2d2d445 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: .default) } - 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: .current, modes: .default, .eventTracking) } 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()