From 34add4705d36cac5460b04f63da5fb86b4563f04 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 18 Sep 2015 09:22:44 +0200 Subject: [PATCH 01/81] Update to Swift 2 --- Src/SwiftyTimer.swift | 2 +- Tests/SwiftyTimerTests.xcodeproj/project.pbxproj | 1 + Tests/SwiftyTimerTests/main.swift | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index 3b49dcf..460c1cc 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -80,7 +80,7 @@ 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: NSRunLoop = NSRunLoop.currentRunLoop(), modes: String...) { + public func start(runLoop runLoop: NSRunLoop = NSRunLoop.currentRunLoop(), modes: String...) { let modes = modes.count != 0 ? modes : [NSDefaultRunLoopMode] for mode in modes { diff --git a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj index 25045e0..1c3f8ff 100644 --- a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -89,6 +89,7 @@ 6EE9C14B1B00BB5B00D6B91C /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0640; TargetAttributes = { 6EE9C1521B00BB5B00D6B91C = { diff --git a/Tests/SwiftyTimerTests/main.swift b/Tests/SwiftyTimerTests/main.swift index 06970d4..7c835fb 100644 --- a/Tests/SwiftyTimerTests/main.swift +++ b/Tests/SwiftyTimerTests/main.swift @@ -70,7 +70,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.test7() } - timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode, runLoop: NSRunLoop.currentRunLoop()) + timer.start(runLoop: NSRunLoop.currentRunLoop(), modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode) } func test7() { @@ -78,7 +78,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func done() { - println("All tests passed") + print("All tests passed") app.terminate(self) } } From c48e14226210d9a5f801802bd91546953c13c1c3 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 18 Sep 2015 09:24:16 +0200 Subject: [PATCH 02/81] Small changes HT @delba Closes #10 --- Src/SwiftyTimer.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index 460c1cc..8b1d751 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -25,7 +25,7 @@ import Foundation private class NSTimerActor { - var block: () -> Void + let block: () -> Void init(_ block: () -> Void) { self.block = block @@ -81,7 +81,7 @@ extension NSTimer { /// Specify `runLoop` or `modes` to override these defaults. public func start(runLoop runLoop: NSRunLoop = NSRunLoop.currentRunLoop(), modes: String...) { - let modes = modes.count != 0 ? modes : [NSDefaultRunLoopMode] + let modes = modes.isEmpty ? [NSDefaultRunLoopMode] : modes for mode in modes { runLoop.addTimer(self, forMode: mode) From e771053ca0a6cbe2ce52d19ad160e850312d6fcc Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 18 Sep 2015 09:25:12 +0200 Subject: [PATCH 03/81] Add millisecond helper: 100.ms --- Src/SwiftyTimer.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index 8b1d751..47f0081 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -90,6 +90,7 @@ extension NSTimer { } extension Double { + public var ms: NSTimeInterval { return self / 1000 } public var second: NSTimeInterval { return self } public var seconds: NSTimeInterval { return self } public var minute: NSTimeInterval { return self * 60 } From 7c3bb0ca429201a2961ddbaea178948d2f3af926 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 18 Sep 2015 09:26:34 +0200 Subject: [PATCH 04/81] Update README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ffadcde..016f8a1 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Then import library module like so: import SwiftyTimer ``` -Note that this requires CocoaPods 0.36+, as well as iOS 8 or OS X 10.9+ +Note that this requires iOS 8 or OS X 10.9+ ## More like this @@ -80,6 +80,7 @@ If you like SwiftyTimer, check out [SwiftyUserDefaults](https://github.com/radex You might also be interested in my blog posts which explain the design process behind those libraries: - [Swifty APIs: NSTimer](http://radex.io/swift/nstimer/) - [Swifty APIs: NSUserDefaults](http://radex.io/swift/nsuserdefaults/) +- [Statically-typed NSUserDefaults](http://radex.io/swift/nsuserdefaults/static) - [Swifty methods](http://radex.io/swift/methods/) ### Contributing From 047fa1c8c3e169c32e937bba7daa83a45999fd7e Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 18 Sep 2015 09:27:05 +0200 Subject: [PATCH 05/81] Bump version to 1.2.0 --- SwiftyTimer.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index e868b03..28a327c 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '1.1.0' + s.version = '1.2.0' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' s.homepage = 'https://github.com/radex/SwiftyTimer' From c4d4a8b053d5cc921a48249755077ccee8b6bd04 Mon Sep 17 00:00:00 2001 From: Jerson Michael Perpetua Date: Sat, 14 Nov 2015 16:25:06 +0800 Subject: [PATCH 06/81] Update .gitignore to exclude Carthage artifacts from version control --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 39f8cd5..5f0c580 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,7 @@ xcuserdata/ /Pods/ -/www \ No newline at end of file +/www + +# Carthage +Carthage/ From 547314c22920cbb4b44b5b724251418dbafa5da0 Mon Sep 17 00:00:00 2001 From: Jerson Michael Perpetua Date: Sat, 14 Nov 2015 16:25:46 +0800 Subject: [PATCH 07/81] Add support for Carthage by creating a formal Xcode project for this repository --- Src/Info.plist | 26 ++ SwiftyTimer.xcodeproj/project.pbxproj | 290 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcschemes/SwiftyTimer.xcscheme | 80 +++++ 4 files changed, 403 insertions(+) create mode 100644 Src/Info.plist create mode 100644 SwiftyTimer.xcodeproj/project.pbxproj create mode 100644 SwiftyTimer.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer.xcscheme diff --git a/Src/Info.plist b/Src/Info.plist new file mode 100644 index 0000000..d3de8ee --- /dev/null +++ b/Src/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj new file mode 100644 index 0000000..11b980f --- /dev/null +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -0,0 +1,290 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 3E721AC71BF725A2008AF027 /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 3E721AC01BF7255D008AF027 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyTimer.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3E721AB71BF7255D008AF027 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3E721AB11BF7255C008AF027 = { + isa = PBXGroup; + children = ( + 3E721ABD1BF7255D008AF027 /* SwiftyTimer */, + 3E721ABC1BF7255D008AF027 /* Products */, + ); + sourceTree = ""; + }; + 3E721ABC1BF7255D008AF027 /* Products */ = { + isa = PBXGroup; + children = ( + 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */, + ); + name = Products; + sourceTree = ""; + }; + 3E721ABD1BF7255D008AF027 /* SwiftyTimer */ = { + isa = PBXGroup; + children = ( + 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */, + 3E721AC01BF7255D008AF027 /* Info.plist */, + ); + name = SwiftyTimer; + path = Src; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 3E721AB81BF7255D008AF027 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 3E721ABA1BF7255D008AF027 /* SwiftyTimer */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3E721AC31BF7255D008AF027 /* Build configuration list for PBXNativeTarget "SwiftyTimer" */; + buildPhases = ( + 3E721AB61BF7255D008AF027 /* Sources */, + 3E721AB71BF7255D008AF027 /* Frameworks */, + 3E721AB81BF7255D008AF027 /* Headers */, + 3E721AB91BF7255D008AF027 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftyTimer; + productName = SwiftyTimer; + productReference = 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3E721AB21BF7255C008AF027 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0710; + ORGANIZATIONNAME = "Radosław Pietruszewski"; + TargetAttributes = { + 3E721ABA1BF7255D008AF027 = { + CreatedOnToolsVersion = 7.1; + }; + }; + }; + buildConfigurationList = 3E721AB51BF7255C008AF027 /* Build configuration list for PBXProject "SwiftyTimer" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 3E721AB11BF7255C008AF027; + productRefGroup = 3E721ABC1BF7255D008AF027 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3E721ABA1BF7255D008AF027 /* SwiftyTimer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3E721AB91BF7255D008AF027 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3E721AB61BF7255D008AF027 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3E721AC71BF725A2008AF027 /* SwiftyTimer.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 3E721AC11BF7255D008AF027 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 3E721AC21BF7255D008AF027 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 3E721AC41BF7255D008AF027 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 3E721AC51BF7255D008AF027 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3E721AB51BF7255C008AF027 /* Build configuration list for PBXProject "SwiftyTimer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3E721AC11BF7255D008AF027 /* Debug */, + 3E721AC21BF7255D008AF027 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3E721AC31BF7255D008AF027 /* Build configuration list for PBXNativeTarget "SwiftyTimer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3E721AC41BF7255D008AF027 /* Debug */, + 3E721AC51BF7255D008AF027 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3E721AB21BF7255C008AF027 /* Project object */; +} diff --git a/SwiftyTimer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SwiftyTimer.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..663a8fd --- /dev/null +++ b/SwiftyTimer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer.xcscheme b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer.xcscheme new file mode 100644 index 0000000..8b0756e --- /dev/null +++ b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a1bcc5f5715286c6da20ecb8f1fa260f51068f59 Mon Sep 17 00:00:00 2001 From: Oktawian Chojnacki Date: Fri, 20 Nov 2015 19:19:02 +0100 Subject: [PATCH 08/81] Improved time helpers. --- README.md | 2 + Src/SwiftyTimer.swift | 10 +--- .../project.pbxproj | 4 ++ Tests/SwiftyTimerTests/SwiftyTime.swift | 54 +++++++++++++++++++ Tests/SwiftyTimerTests/main.swift | 4 ++ 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 Tests/SwiftyTimerTests/SwiftyTime.swift diff --git a/README.md b/README.md index 016f8a1..637f784 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,13 @@ SwiftyTimer uses closures instead of target/selector/userInfo. You can specify time intervals with intuitive [Ruby on Rails](http://rubyonrails.org)-like helpers: ```swift +100.miliseconds 1.second 2.5.seconds 5.seconds 10.minutes 1.hour +2.days ``` You can pass method references instead of closures: diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index 47f0081..dc79eff 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -89,12 +89,4 @@ extension NSTimer { } } -extension Double { - public var ms: NSTimeInterval { return self / 1000 } - public var second: NSTimeInterval { return self } - public var seconds: NSTimeInterval { return self } - public var minute: NSTimeInterval { return self * 60 } - public var minutes: NSTimeInterval { return self * 60 } - public var hour: NSTimeInterval { return self * 3600 } - public var hours: NSTimeInterval { return self * 3600 } -} + diff --git a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj index 1c3f8ff..35646b8 100644 --- a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -7,11 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 1AF1E4861BFE6E40004F5DEC /* SwiftyTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF1E4851BFE6E40004F5DEC /* SwiftyTime.swift */; }; 6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1581B00BB5B00D6B91C /* main.swift */; }; 6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 1AF1E4851BFE6E40004F5DEC /* SwiftyTime.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyTime.swift; sourceTree = ""; }; 6EE9C1531B00BB5B00D6B91C /* SwiftyTimerTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyTimerTests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6EE9C1571B00BB5B00D6B91C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6EE9C1581B00BB5B00D6B91C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; @@ -49,6 +51,7 @@ isa = PBXGroup; children = ( 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */, + 1AF1E4851BFE6E40004F5DEC /* SwiftyTime.swift */, 6EE9C1581B00BB5B00D6B91C /* main.swift */, 6EE9C1561B00BB5B00D6B91C /* Supporting Files */, ); @@ -130,6 +133,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 1AF1E4861BFE6E40004F5DEC /* SwiftyTime.swift in Sources */, 6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */, 6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */, ); diff --git a/Tests/SwiftyTimerTests/SwiftyTime.swift b/Tests/SwiftyTimerTests/SwiftyTime.swift new file mode 100644 index 0000000..1fd7020 --- /dev/null +++ b/Tests/SwiftyTimerTests/SwiftyTime.swift @@ -0,0 +1,54 @@ +// +// SwiftyTimer +// +// Copyright (c) 2015 Oktawian Chojnacki and 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 +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// + +import Foundation + +private let miliDivider: Double = 1000 +private let secondsInMinute: Double = 60 +private let minutesInHour: Double = 60 +private let hoursInDay: Double = 24 + +extension Double { + + private func assertOneOrLess(value: Double) -> Double { + assert(self <= 1, "🤓 Use plural property for numbers above 1.") + return value + } + + public var milisecond: NSTimeInterval { return assertOneOrLess(miliseconds) } + public var miliseconds: NSTimeInterval { return self / miliDivider } + public var ms: NSTimeInterval { return miliseconds } + + public var second: NSTimeInterval { return assertOneOrLess(seconds) } + public var seconds: NSTimeInterval { return self } + + public var minute: NSTimeInterval { return assertOneOrLess(minutes) } + public var minutes: NSTimeInterval { return self * secondsInMinute } + + public var hour: NSTimeInterval { return assertOneOrLess(hours)} + public var hours: NSTimeInterval { return minutes * minutesInHour } + + public var day: NSTimeInterval { return assertOneOrLess(days) } + public var days: NSTimeInterval { return hours * hoursInDay } +} diff --git a/Tests/SwiftyTimerTests/main.swift b/Tests/SwiftyTimerTests/main.swift index 7c835fb..012c8d8 100644 --- a/Tests/SwiftyTimerTests/main.swift +++ b/Tests/SwiftyTimerTests/main.swift @@ -14,6 +14,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { assert(1.2.seconds == 1.2) assert(1.5.minutes == 90.0) assert(1.5.hours == 5400.0) + assert(1.3.miliseconds == 0.0013) + assert(0.5.day == 43_200 ) + assert(1.day == 86_400 ) + assert(2.days == 172_800) test2() } From 91eee7cdac1fafbea5c113b428d9dc0c6a836f88 Mon Sep 17 00:00:00 2001 From: Oktawian Chojnacki Date: Thu, 10 Dec 2015 16:29:02 +0100 Subject: [PATCH 09/81] MiLLi. --- README.md | 2 +- .../SwiftyTimerTests => Src}/SwiftyTime.swift | 24 +++++++++---------- .../project.pbxproj | 8 +++---- Tests/SwiftyTimerTests/main.swift | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) rename {Tests/SwiftyTimerTests => Src}/SwiftyTime.swift (63%) diff --git a/README.md b/README.md index 637f784..13c4e13 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ SwiftyTimer uses closures instead of target/selector/userInfo. You can specify time intervals with intuitive [Ruby on Rails](http://rubyonrails.org)-like helpers: ```swift -100.miliseconds +100.milliseconds 1.second 2.5.seconds 5.seconds diff --git a/Tests/SwiftyTimerTests/SwiftyTime.swift b/Src/SwiftyTime.swift similarity index 63% rename from Tests/SwiftyTimerTests/SwiftyTime.swift rename to Src/SwiftyTime.swift index 1fd7020..e53fe3c 100644 --- a/Tests/SwiftyTimerTests/SwiftyTime.swift +++ b/Src/SwiftyTime.swift @@ -24,7 +24,7 @@ import Foundation -private let miliDivider: Double = 1000 +private let milliDivider: Double = 1000 private let secondsInMinute: Double = 60 private let minutesInHour: Double = 60 private let hoursInDay: Double = 24 @@ -36,19 +36,19 @@ extension Double { return value } - public var milisecond: NSTimeInterval { return assertOneOrLess(miliseconds) } - public var miliseconds: NSTimeInterval { return self / miliDivider } - public var ms: NSTimeInterval { return miliseconds } + public var millisecond: NSTimeInterval { return assertOneOrLess(milliseconds) } + public var milliseconds: NSTimeInterval { return self / milliDivider } + public var ms: NSTimeInterval { return milliseconds } - public var second: NSTimeInterval { return assertOneOrLess(seconds) } - public var seconds: NSTimeInterval { return self } + public var second: NSTimeInterval { return assertOneOrLess(seconds) } + public var seconds: NSTimeInterval { return self } - public var minute: NSTimeInterval { return assertOneOrLess(minutes) } - public var minutes: NSTimeInterval { return self * secondsInMinute } + public var minute: NSTimeInterval { return assertOneOrLess(minutes) } + public var minutes: NSTimeInterval { return self * secondsInMinute } - public var hour: NSTimeInterval { return assertOneOrLess(hours)} - public var hours: NSTimeInterval { return minutes * minutesInHour } + public var hour: NSTimeInterval { return assertOneOrLess(hours)} + public var hours: NSTimeInterval { return minutes * minutesInHour } - public var day: NSTimeInterval { return assertOneOrLess(days) } - public var days: NSTimeInterval { return hours * hoursInDay } + public var day: NSTimeInterval { return assertOneOrLess(days) } + public var days: NSTimeInterval { return hours * hoursInDay } } diff --git a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj index 35646b8..5ba7122 100644 --- a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -7,13 +7,13 @@ objects = { /* Begin PBXBuildFile section */ - 1AF1E4861BFE6E40004F5DEC /* SwiftyTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF1E4851BFE6E40004F5DEC /* SwiftyTime.swift */; }; + 1A4561A11C19D12600313D20 /* SwiftyTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A4561A01C19D12600313D20 /* SwiftyTime.swift */; }; 6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1581B00BB5B00D6B91C /* main.swift */; }; 6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 1AF1E4851BFE6E40004F5DEC /* SwiftyTime.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyTime.swift; sourceTree = ""; }; + 1A4561A01C19D12600313D20 /* SwiftyTime.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftyTime.swift; path = ../../Src/SwiftyTime.swift; sourceTree = ""; }; 6EE9C1531B00BB5B00D6B91C /* SwiftyTimerTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyTimerTests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6EE9C1571B00BB5B00D6B91C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6EE9C1581B00BB5B00D6B91C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; @@ -50,8 +50,8 @@ 6EE9C1551B00BB5B00D6B91C /* SwiftyTimerTests */ = { isa = PBXGroup; children = ( + 1A4561A01C19D12600313D20 /* SwiftyTime.swift */, 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */, - 1AF1E4851BFE6E40004F5DEC /* SwiftyTime.swift */, 6EE9C1581B00BB5B00D6B91C /* main.swift */, 6EE9C1561B00BB5B00D6B91C /* Supporting Files */, ); @@ -133,7 +133,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1AF1E4861BFE6E40004F5DEC /* SwiftyTime.swift in Sources */, + 1A4561A11C19D12600313D20 /* SwiftyTime.swift in Sources */, 6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */, 6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */, ); diff --git a/Tests/SwiftyTimerTests/main.swift b/Tests/SwiftyTimerTests/main.swift index 012c8d8..e33639e 100644 --- a/Tests/SwiftyTimerTests/main.swift +++ b/Tests/SwiftyTimerTests/main.swift @@ -14,7 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { assert(1.2.seconds == 1.2) assert(1.5.minutes == 90.0) assert(1.5.hours == 5400.0) - assert(1.3.miliseconds == 0.0013) + assert(1.3.milliseconds == 0.0013) assert(0.5.day == 43_200 ) assert(1.day == 86_400 ) assert(2.days == 172_800) From 4dfa99a327842a8865359a1693725965fcac8689 Mon Sep 17 00:00:00 2001 From: Oktawian Chojnacki Date: Thu, 10 Dec 2015 16:48:00 +0100 Subject: [PATCH 10/81] Formatting improvement. --- Src/SwiftyTime.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Src/SwiftyTime.swift b/Src/SwiftyTime.swift index e53fe3c..303f764 100644 --- a/Src/SwiftyTime.swift +++ b/Src/SwiftyTime.swift @@ -36,19 +36,19 @@ extension Double { return value } - public var millisecond: NSTimeInterval { return assertOneOrLess(milliseconds) } + public var millisecond: NSTimeInterval { return assertOneOrLess(milliseconds) } public var milliseconds: NSTimeInterval { return self / milliDivider } - public var ms: NSTimeInterval { return milliseconds } + public var ms: NSTimeInterval { return milliseconds } - public var second: NSTimeInterval { return assertOneOrLess(seconds) } - public var seconds: NSTimeInterval { return self } + public var second: NSTimeInterval { return assertOneOrLess(seconds) } + public var seconds: NSTimeInterval { return self } - public var minute: NSTimeInterval { return assertOneOrLess(minutes) } - public var minutes: NSTimeInterval { return self * secondsInMinute } + public var minute: NSTimeInterval { return assertOneOrLess(minutes) } + public var minutes: NSTimeInterval { return self * secondsInMinute } - public var hour: NSTimeInterval { return assertOneOrLess(hours)} - public var hours: NSTimeInterval { return minutes * minutesInHour } + public var hour: NSTimeInterval { return assertOneOrLess(hours)} + public var hours: NSTimeInterval { return minutes * minutesInHour } - public var day: NSTimeInterval { return assertOneOrLess(days) } - public var days: NSTimeInterval { return hours * hoursInDay } + public var day: NSTimeInterval { return assertOneOrLess(days) } + public var days: NSTimeInterval { return hours * hoursInDay } } From 3479a0512652719393607929107aad7129d5223e Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:04:00 +0100 Subject: [PATCH 11/81] iOS 8 deployment target --- SwiftyTimer.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 11b980f..c9ea313 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -174,7 +174,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -216,7 +216,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; From 45d01d4f3d47cbcdee052999ea3daf5884b74af7 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:09:51 +0100 Subject: [PATCH 12/81] Add SwiftyTimer.h --- Src/SwiftyTimer.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Src/SwiftyTimer.h diff --git a/Src/SwiftyTimer.h b/Src/SwiftyTimer.h new file mode 100644 index 0000000..2c112cd --- /dev/null +++ b/Src/SwiftyTimer.h @@ -0,0 +1,4 @@ +#import + +FOUNDATION_EXPORT double SwiftyTimerVersionNumber; +FOUNDATION_EXPORT const unsigned char SwiftyTimerVersionString[]; \ No newline at end of file From ee88da1996b75491677ec923ff8f66fd0de16900 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:10:04 +0100 Subject: [PATCH 13/81] Add Mac target --- SwiftyTimer.xcodeproj/project.pbxproj | 110 ++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index c9ea313..d6c2cc5 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -8,12 +8,16 @@ /* Begin PBXBuildFile section */ 3E721AC71BF725A2008AF027 /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */; }; + 6E7E40931C84B2C60030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6E7E40941C84B2C70030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3E721AC01BF7255D008AF027 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyTimer.swift; sourceTree = ""; }; + 6E7E408A1C84B1A20030CEBB /* SwiftyTimerMac.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimerMac.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftyTimer.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -24,6 +28,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40861C84B1A20030CEBB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -39,6 +50,7 @@ isa = PBXGroup; children = ( 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */, + 6E7E408A1C84B1A20030CEBB /* SwiftyTimerMac.framework */, ); name = Products; sourceTree = ""; @@ -48,6 +60,7 @@ children = ( 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */, 3E721AC01BF7255D008AF027 /* Info.plist */, + 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */, ); name = SwiftyTimer; path = Src; @@ -60,6 +73,15 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 6E7E40931C84B2C60030CEBB /* SwiftyTimer.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 6E7E40871C84B1A20030CEBB /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 6E7E40941C84B2C70030CEBB /* SwiftyTimer.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -84,6 +106,24 @@ productReference = 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */; productType = "com.apple.product-type.framework"; }; + 6E7E40891C84B1A20030CEBB /* SwiftyTimerMac */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6E7E408F1C84B1A20030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimerMac" */; + buildPhases = ( + 6E7E40851C84B1A20030CEBB /* Sources */, + 6E7E40861C84B1A20030CEBB /* Frameworks */, + 6E7E40871C84B1A20030CEBB /* Headers */, + 6E7E40881C84B1A20030CEBB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftyTimerMac; + productName = SwiftyTimerMac; + productReference = 6E7E408A1C84B1A20030CEBB /* SwiftyTimerMac.framework */; + productType = "com.apple.product-type.framework"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -96,6 +136,9 @@ 3E721ABA1BF7255D008AF027 = { CreatedOnToolsVersion = 7.1; }; + 6E7E40891C84B1A20030CEBB = { + CreatedOnToolsVersion = 7.2; + }; }; }; buildConfigurationList = 3E721AB51BF7255C008AF027 /* Build configuration list for PBXProject "SwiftyTimer" */; @@ -111,6 +154,7 @@ projectRoot = ""; targets = ( 3E721ABA1BF7255D008AF027 /* SwiftyTimer */, + 6E7E40891C84B1A20030CEBB /* SwiftyTimerMac */, ); }; /* End PBXProject section */ @@ -123,6 +167,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40881C84B1A20030CEBB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -134,6 +185,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40851C84B1A20030CEBB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ @@ -175,6 +233,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -217,6 +276,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.9; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -263,6 +323,48 @@ }; name = Release; }; + 6E7E40901C84B1A20030CEBB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimerMac; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 6E7E40911C84B1A20030CEBB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimerMac; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -284,6 +386,14 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 6E7E408F1C84B1A20030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimerMac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6E7E40901C84B1A20030CEBB /* Debug */, + 6E7E40911C84B1A20030CEBB /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; /* End XCConfigurationList section */ }; rootObject = 3E721AB21BF7255C008AF027 /* Project object */; From 3f1ece61d4a733872acc08c4403aaad1afd51cbc Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:11:46 +0100 Subject: [PATCH 14/81] Build Mac target as SwiftyTimer.framework --- SwiftyTimer.xcodeproj/project.pbxproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index d6c2cc5..0a8561b 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -16,7 +16,7 @@ 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3E721AC01BF7255D008AF027 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyTimer.swift; sourceTree = ""; }; - 6E7E408A1C84B1A20030CEBB /* SwiftyTimerMac.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimerMac.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftyTimer.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -50,7 +50,7 @@ isa = PBXGroup; children = ( 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */, - 6E7E408A1C84B1A20030CEBB /* SwiftyTimerMac.framework */, + 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */, ); name = Products; sourceTree = ""; @@ -121,7 +121,7 @@ ); name = SwiftyTimerMac; productName = SwiftyTimerMac; - productReference = 6E7E408A1C84B1A20030CEBB /* SwiftyTimerMac.framework */; + productReference = 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */; productType = "com.apple.product-type.framework"; }; /* End PBXNativeTarget section */ @@ -338,7 +338,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimerMac; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; }; @@ -359,7 +359,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimerMac; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; }; From af6b37f8be29b63a23fba40d144fd77e6e5c6e5b Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:13:10 +0100 Subject: [PATCH 15/81] Add tvOS target --- SwiftyTimer.xcodeproj/project.pbxproj | 98 +++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 0a8561b..92bf29b 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyTimer.swift; sourceTree = ""; }; 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftyTimer.h; sourceTree = ""; }; + 6E7E409A1C84B3790030CEBB /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,6 +36,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40961C84B3790030CEBB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -51,6 +59,7 @@ children = ( 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */, 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */, + 6E7E409A1C84B3790030CEBB /* SwiftyTimer.framework */, ); name = Products; sourceTree = ""; @@ -85,6 +94,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40971C84B3790030CEBB /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ @@ -124,6 +140,24 @@ productReference = 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */; productType = "com.apple.product-type.framework"; }; + 6E7E40991C84B3790030CEBB /* SwiftyTimer tvOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6E7E409F1C84B3790030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer tvOS" */; + buildPhases = ( + 6E7E40951C84B3790030CEBB /* Sources */, + 6E7E40961C84B3790030CEBB /* Frameworks */, + 6E7E40971C84B3790030CEBB /* Headers */, + 6E7E40981C84B3790030CEBB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "SwiftyTimer tvOS"; + productName = "SwiftyTimer tvOS"; + productReference = 6E7E409A1C84B3790030CEBB /* SwiftyTimer.framework */; + productType = "com.apple.product-type.framework"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -139,6 +173,9 @@ 6E7E40891C84B1A20030CEBB = { CreatedOnToolsVersion = 7.2; }; + 6E7E40991C84B3790030CEBB = { + CreatedOnToolsVersion = 7.2; + }; }; }; buildConfigurationList = 3E721AB51BF7255C008AF027 /* Build configuration list for PBXProject "SwiftyTimer" */; @@ -155,6 +192,7 @@ targets = ( 3E721ABA1BF7255D008AF027 /* SwiftyTimer */, 6E7E40891C84B1A20030CEBB /* SwiftyTimerMac */, + 6E7E40991C84B3790030CEBB /* SwiftyTimer tvOS */, ); }; /* End PBXProject section */ @@ -174,6 +212,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40981C84B3790030CEBB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -192,6 +237,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40951C84B3790030CEBB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ @@ -365,6 +417,44 @@ }; name = Release; }; + 6E7E40A01C84B3790030CEBB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.radex.SwiftyTimer-tvOS"; + PRODUCT_NAME = SwiftyTimer; + SDKROOT = appletvos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Debug; + }; + 6E7E40A11C84B3790030CEBB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.radex.SwiftyTimer-tvOS"; + PRODUCT_NAME = SwiftyTimer; + SDKROOT = appletvos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -394,6 +484,14 @@ ); defaultConfigurationIsVisible = 0; }; + 6E7E409F1C84B3790030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer tvOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6E7E40A01C84B3790030CEBB /* Debug */, + 6E7E40A11C84B3790030CEBB /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; /* End XCConfigurationList section */ }; rootObject = 3E721AB21BF7255C008AF027 /* Project object */; From e6a2f2b3cfd89358ffa89f16117725d50eac45da Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:14:55 +0100 Subject: [PATCH 16/81] fix warnings, use same bundle identifier, app extension apis only --- SwiftyTimer.xcodeproj/project.pbxproj | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 92bf29b..4dc8669 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 3E721AC71BF725A2008AF027 /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */; }; 6E7E40931C84B2C60030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6E7E40941C84B2C70030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6E7E40A21C84B3F40030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -98,6 +99,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 6E7E40A21C84B3F40030CEBB /* SwiftyTimer.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -341,6 +343,7 @@ 3E721AC41BF7255D008AF027 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -360,6 +363,7 @@ 3E721AC51BF7255D008AF027 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -378,6 +382,7 @@ 6E7E40901C84B1A20030CEBB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; @@ -389,7 +394,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; - PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimerMac; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -399,6 +404,7 @@ 6E7E40911C84B1A20030CEBB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; @@ -410,7 +416,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; - PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimerMac; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -420,6 +426,7 @@ 6E7E40A01C84B3790030CEBB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -427,7 +434,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "io.radex.SwiftyTimer-tvOS"; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; @@ -439,6 +446,7 @@ 6E7E40A11C84B3790030CEBB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -446,7 +454,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "io.radex.SwiftyTimer-tvOS"; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = SwiftyTimer; SDKROOT = appletvos; SKIP_INSTALL = YES; From 7ce5fc1053a573dd7e71e1fc5164e062a66fdde2 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:16:46 +0100 Subject: [PATCH 17/81] Add watchOS target --- SwiftyTimer.xcodeproj/project.pbxproj | 102 ++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 4dc8669..f42df2e 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 6E7E40931C84B2C60030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6E7E40941C84B2C70030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6E7E40A21C84B3F40030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6E7E40B01C84B43A0030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -20,6 +21,7 @@ 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftyTimer.h; sourceTree = ""; }; 6E7E409A1C84B3790030CEBB /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 6E7E40A81C84B4240030CEBB /* SwiftyTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -44,6 +46,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40A41C84B4240030CEBB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -61,6 +70,7 @@ 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */, 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */, 6E7E409A1C84B3790030CEBB /* SwiftyTimer.framework */, + 6E7E40A81C84B4240030CEBB /* SwiftyTimer.framework */, ); name = Products; sourceTree = ""; @@ -103,6 +113,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40A51C84B4240030CEBB /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 6E7E40B01C84B43A0030CEBB /* SwiftyTimer.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ @@ -160,6 +178,24 @@ productReference = 6E7E409A1C84B3790030CEBB /* SwiftyTimer.framework */; productType = "com.apple.product-type.framework"; }; + 6E7E40A71C84B4240030CEBB /* SwiftyTimer watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6E7E40AD1C84B4240030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer watchOS" */; + buildPhases = ( + 6E7E40A31C84B4240030CEBB /* Sources */, + 6E7E40A41C84B4240030CEBB /* Frameworks */, + 6E7E40A51C84B4240030CEBB /* Headers */, + 6E7E40A61C84B4240030CEBB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "SwiftyTimer watchOS"; + productName = "SwiftyTimer watchOS"; + productReference = 6E7E40A81C84B4240030CEBB /* SwiftyTimer.framework */; + productType = "com.apple.product-type.framework"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -178,6 +214,9 @@ 6E7E40991C84B3790030CEBB = { CreatedOnToolsVersion = 7.2; }; + 6E7E40A71C84B4240030CEBB = { + CreatedOnToolsVersion = 7.2; + }; }; }; buildConfigurationList = 3E721AB51BF7255C008AF027 /* Build configuration list for PBXProject "SwiftyTimer" */; @@ -195,6 +234,7 @@ 3E721ABA1BF7255D008AF027 /* SwiftyTimer */, 6E7E40891C84B1A20030CEBB /* SwiftyTimerMac */, 6E7E40991C84B3790030CEBB /* SwiftyTimer tvOS */, + 6E7E40A71C84B4240030CEBB /* SwiftyTimer watchOS */, ); }; /* End PBXProject section */ @@ -221,6 +261,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40A61C84B4240030CEBB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -246,6 +293,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6E7E40A31C84B4240030CEBB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ @@ -463,6 +517,46 @@ }; name = Release; }; + 6E7E40AE1C84B4240030CEBB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; + PRODUCT_NAME = SwiftyTimer; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Debug; + }; + 6E7E40AF1C84B4240030CEBB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; + PRODUCT_NAME = SwiftyTimer; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -500,6 +594,14 @@ ); defaultConfigurationIsVisible = 0; }; + 6E7E40AD1C84B4240030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6E7E40AE1C84B4240030CEBB /* Debug */, + 6E7E40AF1C84B4240030CEBB /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; /* End XCConfigurationList section */ }; rootObject = 3E721AB21BF7255C008AF027 /* Project object */; From df822e180769cf8bf3b7180523e8ad07cc963eab Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:19:38 +0100 Subject: [PATCH 18/81] Tweak Xcode settings --- SwiftyTimer.xcodeproj/project.pbxproj | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index f42df2e..ad6b52d 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -12,6 +12,9 @@ 6E7E40941C84B2C70030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6E7E40A21C84B3F40030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6E7E40B01C84B43A0030CEBB /* SwiftyTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6E7E40B11C84B4B40030CEBB /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */; }; + 6E7E40B21C84B4B40030CEBB /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */; }; + 6E7E40B31C84B4B40030CEBB /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E721AC61BF725A2008AF027 /* SwiftyTimer.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -142,9 +145,9 @@ productReference = 3E721ABB1BF7255D008AF027 /* SwiftyTimer.framework */; productType = "com.apple.product-type.framework"; }; - 6E7E40891C84B1A20030CEBB /* SwiftyTimerMac */ = { + 6E7E40891C84B1A20030CEBB /* SwiftyTimer OS X */ = { isa = PBXNativeTarget; - buildConfigurationList = 6E7E408F1C84B1A20030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimerMac" */; + buildConfigurationList = 6E7E408F1C84B1A20030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer OS X" */; buildPhases = ( 6E7E40851C84B1A20030CEBB /* Sources */, 6E7E40861C84B1A20030CEBB /* Frameworks */, @@ -155,7 +158,7 @@ ); dependencies = ( ); - name = SwiftyTimerMac; + name = "SwiftyTimer OS X"; productName = SwiftyTimerMac; productReference = 6E7E408A1C84B1A20030CEBB /* SwiftyTimer.framework */; productType = "com.apple.product-type.framework"; @@ -232,7 +235,7 @@ projectRoot = ""; targets = ( 3E721ABA1BF7255D008AF027 /* SwiftyTimer */, - 6E7E40891C84B1A20030CEBB /* SwiftyTimerMac */, + 6E7E40891C84B1A20030CEBB /* SwiftyTimer OS X */, 6E7E40991C84B3790030CEBB /* SwiftyTimer tvOS */, 6E7E40A71C84B4240030CEBB /* SwiftyTimer watchOS */, ); @@ -283,6 +286,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 6E7E40B11C84B4B40030CEBB /* SwiftyTimer.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -290,6 +294,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 6E7E40B21C84B4B40030CEBB /* SwiftyTimer.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -297,6 +302,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 6E7E40B31C84B4B40030CEBB /* SwiftyTimer.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -578,13 +584,14 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 6E7E408F1C84B1A20030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimerMac" */ = { + 6E7E408F1C84B1A20030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer OS X" */ = { isa = XCConfigurationList; buildConfigurations = ( 6E7E40901C84B1A20030CEBB /* Debug */, 6E7E40911C84B1A20030CEBB /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 6E7E409F1C84B3790030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer tvOS" */ = { isa = XCConfigurationList; @@ -593,6 +600,7 @@ 6E7E40A11C84B3790030CEBB /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 6E7E40AD1C84B4240030CEBB /* Build configuration list for PBXNativeTarget "SwiftyTimer watchOS" */ = { isa = XCConfigurationList; @@ -601,6 +609,7 @@ 6E7E40AF1C84B4240030CEBB /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; From 613bc4020874238dea59540c5a083592dbe9e3e6 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:20:13 +0100 Subject: [PATCH 19/81] Merge all code into one file For compilation performance and ease of manual installation --- Src/SwiftyTime.swift | 54 ------------------------------------------- Src/SwiftyTimer.swift | 29 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 54 deletions(-) delete mode 100644 Src/SwiftyTime.swift diff --git a/Src/SwiftyTime.swift b/Src/SwiftyTime.swift deleted file mode 100644 index 303f764..0000000 --- a/Src/SwiftyTime.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// SwiftyTimer -// -// Copyright (c) 2015 Oktawian Chojnacki and 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 -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// - -import Foundation - -private let milliDivider: Double = 1000 -private let secondsInMinute: Double = 60 -private let minutesInHour: Double = 60 -private let hoursInDay: Double = 24 - -extension Double { - - private func assertOneOrLess(value: Double) -> Double { - assert(self <= 1, "🤓 Use plural property for numbers above 1.") - return value - } - - public var millisecond: NSTimeInterval { return assertOneOrLess(milliseconds) } - public var milliseconds: NSTimeInterval { return self / milliDivider } - public var ms: NSTimeInterval { return milliseconds } - - public var second: NSTimeInterval { return assertOneOrLess(seconds) } - public var seconds: NSTimeInterval { return self } - - public var minute: NSTimeInterval { return assertOneOrLess(minutes) } - public var minutes: NSTimeInterval { return self * secondsInMinute } - - public var hour: NSTimeInterval { return assertOneOrLess(hours)} - public var hours: NSTimeInterval { return minutes * minutesInHour } - - public var day: NSTimeInterval { return assertOneOrLess(days) } - public var days: NSTimeInterval { return hours * hoursInDay } -} diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index dc79eff..7916138 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -89,4 +89,33 @@ extension NSTimer { } } +// MARK: - Time extensions +private let milliDivider: Double = 1000 +private let secondsInMinute: Double = 60 +private let minutesInHour: Double = 60 +private let hoursInDay: Double = 24 + +extension Double { + + private func assertOneOrLess(value: Double) -> Double { + assert(self <= 1, "🤓 Use plural property for numbers above 1.") + return value + } + + public var millisecond: NSTimeInterval { return assertOneOrLess(milliseconds) } + public var milliseconds: NSTimeInterval { return self / milliDivider } + public var ms: NSTimeInterval { return milliseconds } + + public var second: NSTimeInterval { return assertOneOrLess(seconds) } + public var seconds: NSTimeInterval { return self } + + public var minute: NSTimeInterval { return assertOneOrLess(minutes) } + public var minutes: NSTimeInterval { return self * secondsInMinute } + + public var hour: NSTimeInterval { return assertOneOrLess(hours)} + public var hours: NSTimeInterval { return minutes * minutesInHour } + + public var day: NSTimeInterval { return assertOneOrLess(days) } + public var days: NSTimeInterval { return hours * hoursInDay } +} From 98fe0736689c8b2a3042c676771fc6ff620df66f Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:22:45 +0100 Subject: [PATCH 20/81] Simplify and make the grammar assert more correct --- Src/SwiftyTimer.swift | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index 7916138..5c82ed0 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -91,31 +91,26 @@ extension NSTimer { // MARK: - Time extensions -private let milliDivider: Double = 1000 -private let secondsInMinute: Double = 60 -private let minutesInHour: Double = 60 -private let hoursInDay: Double = 24 - extension Double { - private func assertOneOrLess(value: Double) -> Double { - assert(self <= 1, "🤓 Use plural property for numbers above 1.") + private func assertOne(value: Double) -> Double { + assert(self == 1, "🤓 Use plural property for numbers other than 1") return value } - public var millisecond: NSTimeInterval { return assertOneOrLess(milliseconds) } - public var milliseconds: NSTimeInterval { return self / milliDivider } - public var ms: NSTimeInterval { return milliseconds } + public var millisecond: NSTimeInterval { return assertOne(milliseconds) } + public var milliseconds: NSTimeInterval { return self / 1000 } + public var ms: NSTimeInterval { return self / 1000 } - public var second: NSTimeInterval { return assertOneOrLess(seconds) } + public var second: NSTimeInterval { return assertOne(seconds) } public var seconds: NSTimeInterval { return self } - public var minute: NSTimeInterval { return assertOneOrLess(minutes) } - public var minutes: NSTimeInterval { return self * secondsInMinute } + public var minute: NSTimeInterval { return assertOne(minutes) } + public var minutes: NSTimeInterval { return self * 60 } - public var hour: NSTimeInterval { return assertOneOrLess(hours)} - public var hours: NSTimeInterval { return minutes * minutesInHour } + public var hour: NSTimeInterval { return assertOne(hours) } + public var hours: NSTimeInterval { return self * 3600 } - public var day: NSTimeInterval { return assertOneOrLess(days) } - public var days: NSTimeInterval { return hours * hoursInDay } + public var day: NSTimeInterval { return assertOne(days) } + public var days: NSTimeInterval { return self * 3600 * 24 } } From 4965e351e09936ec54f66c4fa900e4049c58a4a0 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:24:35 +0100 Subject: [PATCH 21/81] Tweak documentation --- Src/SwiftyTimer.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index 5c82ed0..fb6701e 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -37,12 +37,11 @@ private class NSTimerActor { } extension NSTimer { - // NOTE: `new` class functions are a workaround for a crashing bug when using convenience initializers (18720947) - /// Create a timer that will call `block` once after the specified time. /// - /// **Note:** the timer won't fire until it's scheduled on the run loop. - /// Use `NSTimer.after` to create and schedule a timer in one step. + /// - Note: The timer won't fire until it's scheduled on the run loop. + /// 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 { let actor = NSTimerActor(block) @@ -51,8 +50,9 @@ extension NSTimer { /// Create a timer that will call `block` repeatedly in specified time intervals. /// - /// **Note:** the timer won't fire until it's scheduled on the run loop. - /// Use `NSTimer.every` to create and schedule a timer in one step. + /// - Note: The timer won't fire until it's scheduled on the run loop. + /// 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(every interval: NSTimeInterval, _ block: () -> Void) -> NSTimer { let actor = NSTimerActor(block) From 96dedf2c5eaed7e15aec5c1bd3bc61bb85357e06 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:27:08 +0100 Subject: [PATCH 22/81] Actually just remove the grammar nazi assert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here’s why: You want to do 0.5.day (because “half a day”), but 0.3.seconds (“zero point three seconds”), not 0.3.second. So. Whatever. --- Src/SwiftyTimer.swift | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Src/SwiftyTimer.swift b/Src/SwiftyTimer.swift index fb6701e..67e59c1 100644 --- a/Src/SwiftyTimer.swift +++ b/Src/SwiftyTimer.swift @@ -92,25 +92,19 @@ extension NSTimer { // MARK: - Time extensions extension Double { - - private func assertOne(value: Double) -> Double { - assert(self == 1, "🤓 Use plural property for numbers other than 1") - return value - } - - public var millisecond: NSTimeInterval { return assertOne(milliseconds) } + public var millisecond: NSTimeInterval { return self / 1000 } public var milliseconds: NSTimeInterval { return self / 1000 } public var ms: NSTimeInterval { return self / 1000 } - public var second: NSTimeInterval { return assertOne(seconds) } + public var second: NSTimeInterval { return self } public var seconds: NSTimeInterval { return self } - public var minute: NSTimeInterval { return assertOne(minutes) } + public var minute: NSTimeInterval { return self * 60 } public var minutes: NSTimeInterval { return self * 60 } - public var hour: NSTimeInterval { return assertOne(hours) } + public var hour: NSTimeInterval { return self * 3600 } public var hours: NSTimeInterval { return self * 3600 } - public var day: NSTimeInterval { return assertOne(days) } + public var day: NSTimeInterval { return self * 3600 * 24 } public var days: NSTimeInterval { return self * 3600 * 24 } } From 0f8cf8acf9cca91eb85232666261f4661296870d Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:27:12 +0100 Subject: [PATCH 23/81] Fix tests --- Tests/SwiftyTimerTests.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj index 5ba7122..1c3f8ff 100644 --- a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -7,13 +7,11 @@ objects = { /* Begin PBXBuildFile section */ - 1A4561A11C19D12600313D20 /* SwiftyTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A4561A01C19D12600313D20 /* SwiftyTime.swift */; }; 6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1581B00BB5B00D6B91C /* main.swift */; }; 6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 1A4561A01C19D12600313D20 /* SwiftyTime.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftyTime.swift; path = ../../Src/SwiftyTime.swift; sourceTree = ""; }; 6EE9C1531B00BB5B00D6B91C /* SwiftyTimerTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyTimerTests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6EE9C1571B00BB5B00D6B91C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6EE9C1581B00BB5B00D6B91C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; @@ -50,7 +48,6 @@ 6EE9C1551B00BB5B00D6B91C /* SwiftyTimerTests */ = { isa = PBXGroup; children = ( - 1A4561A01C19D12600313D20 /* SwiftyTime.swift */, 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */, 6EE9C1581B00BB5B00D6B91C /* main.swift */, 6EE9C1561B00BB5B00D6B91C /* Supporting Files */, @@ -133,7 +130,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1A4561A11C19D12600313D20 /* SwiftyTime.swift in Sources */, 6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */, 6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */, ); From 67cd76f9a4347f45c96bf43839aa5cafbc8f3c07 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:36:24 +0100 Subject: [PATCH 24/81] Src -> Sources/ --- README.md | 2 +- {Src => Sources}/Info.plist | 0 {Src => Sources}/SwiftyTimer.h | 0 {Src => Sources}/SwiftyTimer.swift | 2 +- SwiftyTimer.podspec | 2 +- SwiftyTimer.xcodeproj/project.pbxproj | 18 +++++++++--------- 6 files changed, 12 insertions(+), 12 deletions(-) rename {Src => Sources}/Info.plist (100%) rename {Src => Sources}/SwiftyTimer.h (100%) rename {Src => Sources}/SwiftyTimer.swift (98%) diff --git a/README.md b/README.md index 13c4e13..34a0dde 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode) ## Installation -The simplest way to install this library is to copy `Src/SwiftyTimer.swift` to your project. There's no step two! +The simplest way to install this library is to copy `Sources/SwiftyTimer.swift` to your project. There's no step two! #### CocoaPods diff --git a/Src/Info.plist b/Sources/Info.plist similarity index 100% rename from Src/Info.plist rename to Sources/Info.plist diff --git a/Src/SwiftyTimer.h b/Sources/SwiftyTimer.h similarity index 100% rename from Src/SwiftyTimer.h rename to Sources/SwiftyTimer.h diff --git a/Src/SwiftyTimer.swift b/Sources/SwiftyTimer.swift similarity index 98% rename from Src/SwiftyTimer.swift rename to Sources/SwiftyTimer.swift index 67e59c1..5a58c43 100644 --- a/Src/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -1,7 +1,7 @@ // // SwiftyTimer // -// 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 diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index 28a327c..4cad706 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -11,5 +11,5 @@ Pod::Spec.new do |s| s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.9' - s.source_files = 'Src/*.swift' + s.source_files = 'Sources/*.swift' end \ No newline at end of file diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index ad6b52d..2f2a00e 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -86,7 +86,7 @@ 6E7E40921C84B2970030CEBB /* SwiftyTimer.h */, ); name = SwiftyTimer; - path = Src; + path = Sources; sourceTree = ""; }; /* End PBXGroup section */ @@ -409,7 +409,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -429,7 +429,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -450,7 +450,7 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_VERSION = A; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; @@ -472,7 +472,7 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_VERSION = A; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; @@ -491,7 +491,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; @@ -511,7 +511,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; @@ -531,7 +531,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; @@ -551,7 +551,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Src/Info.plist"; + INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; From 048ad51cafcbe7f162b82aca6fac9176c58bbe89 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:43:19 +0100 Subject: [PATCH 25/81] Podspec: Add tvOS, watchOS support --- SwiftyTimer.podspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index 4cad706..38beace 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -10,6 +10,8 @@ Pod::Spec.new do |s| s.requires_arc = true s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '9.0' + s.watchos.deployment_target = '2.0' s.source_files = 'Sources/*.swift' end \ No newline at end of file From d049023a16e0e3a089b7e8aee9b7395964796963 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:43:26 +0100 Subject: [PATCH 26/81] Add CHANGELOG.md --- CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..13a79be --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +### master + +- Add Carthage support +- Add tvOS and watchOS support + +### 1.2.0 (2015-09-18) + +- Update to Swift 2 +- Add millisecond helper (`100.ms`) + +### 1.1.0 (2015-05-13) + +- Add `start(runLoop:, modes:)` +- Refactoring + +### 1.0.0 (2015-05-11) + +- 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 From 9cc8769bfa2f1f7b13ed53ac01c3ecbd2238aa71 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:50:08 +0100 Subject: [PATCH 27/81] Update Readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 34a0dde..7b1cf90 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # SwiftyTimer -SwiftyTimer is a set of extensions to make the `NSTimer` API cleaner, nicer to use, and at home with Swift's syntax. +![Platforms](https://img.shields.io/badge/platforms-ios%20%7C%20osx%20%7C%20watchos%20%7C%20tvos-lightgrey.svg) +[![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.1-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. Read [Swifty APIs: NSTimer](http://radex.io/swift/nstimer/) for more information about this project. From 6370df43bd9aece32e0119600ec6a936d1fae143 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:51:16 +0100 Subject: [PATCH 28/81] Update Readme --- README.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7b1cf90..b529bc1 100644 --- a/README.md +++ b/README.md @@ -63,23 +63,35 @@ timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode) ## Installation -The simplest way to install this library is to copy `Sources/SwiftyTimer.swift` to your project. There's no step two! - -#### CocoaPods - -You can also install this library using CocoaPods. Just add this line to your Podfile: +If you're using CocoaPods, just add this line to your Podfile: ```ruby pod 'SwiftyTimer' ``` -Then import library module like so: +Install by running this command in your terminal: + +```sh +pod install +``` + +Then import the library in all files where you use it: ```swift import SwiftyTimer ``` -Note that this requires iOS 8 or OS X 10.9+ +#### Carthage + +Just add to your Cartfile: + +```ruby +github "radex/SwiftyTimer" +``` + +#### Manually + +Simply copy `Sources/SwiftyTimer.swift` to your Xcode project. ## More like this From 117c78d525e4ba05dd71709fd63be54264376111 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:52:42 +0100 Subject: [PATCH 29/81] Bump to 1.3.0 --- CHANGELOG.md | 2 +- SwiftyTimer.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13a79be..21f3c8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### master +### 1.3.0 (2016-02-29) - Add Carthage support - Add tvOS and watchOS support diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index 38beace..6f07d22 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '1.2.0' + s.version = '1.3.0' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' s.homepage = 'https://github.com/radex/SwiftyTimer' From fdf60c9aa8e064dcede8c7c9be4cc128154e88a3 Mon Sep 17 00:00:00 2001 From: radex Date: Mon, 29 Feb 2016 18:54:18 +0100 Subject: [PATCH 30/81] Fix tests project --- Tests/SwiftyTimerTests.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj index 1c3f8ff..a49a698 100644 --- a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj +++ b/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 6EE9C1531B00BB5B00D6B91C /* SwiftyTimerTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyTimerTests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6EE9C1571B00BB5B00D6B91C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6EE9C1581B00BB5B00D6B91C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; - 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftyTimer.swift; path = ../../Src/SwiftyTimer.swift; sourceTree = ""; }; + 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftyTimer.swift; path = ../../Sources/SwiftyTimer.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ From 7290d49b8f3b0ad1281ade689fa24ca650f2da8e Mon Sep 17 00:00:00 2001 From: Ostap Taran Date: Mon, 29 Feb 2016 22:39:01 +0200 Subject: [PATCH 31/81] Removed NSTimerActor. Used CFRunLoopTimerCreateWithHandler instead --- Sources/SwiftyTimer.swift | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index 5a58c43..c76605d 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -24,41 +24,31 @@ import Foundation -private class NSTimerActor { - let block: () -> Void - - init(_ block: () -> Void) { - self.block = block - } - - @objc func fire() { - block() - } -} - extension NSTimer { /// Create a timer that will call `block` once after the specified time. /// /// - Note: The timer won't fire until it's scheduled on the run loop. /// 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 { - let actor = NSTimerActor(block) - return self.init(timeInterval: interval, target: actor, selector: "fire", userInfo: nil, repeats: false) + return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0) { _ in + block() + } } - /// Create a timer that will call `block` repeatedly in specified time intervals. /// /// - Note: The timer won't fire until it's scheduled on the run loop. /// 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(every interval: NSTimeInterval, _ block: () -> Void) -> NSTimer { - let actor = NSTimerActor(block) - return self.init(timeInterval: interval, target: actor, selector: "fire", userInfo: nil, repeats: true) + return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in + block() + } } - + + /// Create and schedule a timer that will call `block` once after the specified time. public class func after(interval: NSTimeInterval, _ block: () -> Void) -> NSTimer { From 0fbea819694b7fea12975fff8a71daf592775889 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 18:30:24 +0100 Subject: [PATCH 32/81] Add Package.swift --- Package.swift | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..097a463 --- /dev/null +++ b/Package.swift @@ -0,0 +1,6 @@ +import PackageDescription + +let package = Package( + exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h"], + dependencies: [] +) \ No newline at end of file From 9f1a8a5bb4d12fbc1c57067d03eae983461f8052 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 18:56:49 +0100 Subject: [PATCH 33/81] Add .travis.yml --- .travis.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..13f147b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: objective-c +cache: cocoapods +rvm: 2.2.2 +osx_image: xcode7.2 + +before_install: +- 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 + +- pod lib lint \ No newline at end of file From cba22cb6e7ba27be454e2d10fd9eaeec0205e055 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 19:04:35 +0100 Subject: [PATCH 34/81] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f3c8b..03d2267 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### master + +- Refactoring (Removed NSTimerActor. Used CFRunLoopTimerCreateWithHandler instead.) #22 @Austinate + ### 1.3.0 (2016-02-29) - Add Carthage support From 9829bd106792d0deb10dc58ed5f7871bd9c76694 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 19:08:01 +0100 Subject: [PATCH 35/81] Tests -> SwiftyTimerTests (fix SwiftPM) --- Package.swift | 2 +- .../SwiftyTimerTests.xcodeproj/project.pbxproj | 0 .../project.xcworkspace/contents.xcworkspacedata | 0 {Tests => SwiftyTimerTests}/SwiftyTimerTests/Info.plist | 0 {Tests => SwiftyTimerTests}/SwiftyTimerTests/main.swift | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename {Tests => SwiftyTimerTests}/SwiftyTimerTests.xcodeproj/project.pbxproj (100%) rename {Tests => SwiftyTimerTests}/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata (100%) rename {Tests => SwiftyTimerTests}/SwiftyTimerTests/Info.plist (100%) rename {Tests => SwiftyTimerTests}/SwiftyTimerTests/main.swift (100%) diff --git a/Package.swift b/Package.swift index 097a463..22d6634 100644 --- a/Package.swift +++ b/Package.swift @@ -1,6 +1,6 @@ import PackageDescription let package = Package( - exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h"], + exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h", "SwiftyTimerTests"], dependencies: [] ) \ No newline at end of file diff --git a/Tests/SwiftyTimerTests.xcodeproj/project.pbxproj b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj similarity index 100% rename from Tests/SwiftyTimerTests.xcodeproj/project.pbxproj rename to SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj diff --git a/Tests/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from Tests/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/Tests/SwiftyTimerTests/Info.plist b/SwiftyTimerTests/SwiftyTimerTests/Info.plist similarity index 100% rename from Tests/SwiftyTimerTests/Info.plist rename to SwiftyTimerTests/SwiftyTimerTests/Info.plist diff --git a/Tests/SwiftyTimerTests/main.swift b/SwiftyTimerTests/SwiftyTimerTests/main.swift similarity index 100% rename from Tests/SwiftyTimerTests/main.swift rename to SwiftyTimerTests/SwiftyTimerTests/main.swift From 18461690ee43750182e5bfb271e56280627388ee Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 19:09:41 +0100 Subject: [PATCH 36/81] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03d2267..0530ab3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### master - Refactoring (Removed NSTimerActor. Used CFRunLoopTimerCreateWithHandler instead.) #22 @Austinate +- Added support for Swift Package Manager ### 1.3.0 (2016-02-29) From b678a5503e4bb148e3fb57ce3cc3d670ac484c41 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 19:14:20 +0100 Subject: [PATCH 37/81] Share SwiftyTimer OS X / watchOS / tvOS schemes --- .../xcschemes/SwiftyTimer OS X.xcscheme | 81 +++++++++++++++++++ .../xcschemes/SwiftyTimer tvOS.xcscheme | 81 +++++++++++++++++++ .../xcschemes/SwiftyTimer watchOS.xcscheme | 81 +++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme create mode 100644 SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer tvOS.xcscheme create mode 100644 SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer watchOS.xcscheme diff --git a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme new file mode 100644 index 0000000..cb1d60a --- /dev/null +++ b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer tvOS.xcscheme b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer tvOS.xcscheme new file mode 100644 index 0000000..afa95ff --- /dev/null +++ b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer tvOS.xcscheme @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer watchOS.xcscheme b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer watchOS.xcscheme new file mode 100644 index 0000000..753846c --- /dev/null +++ b/SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer watchOS.xcscheme @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b313d5cf3a45c190ebfda99e65528279d2266707 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 19:46:31 +0100 Subject: [PATCH 38/81] Share tests scheme --- .../xcschemes/SwiftyTimerTests.xcscheme | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme diff --git a/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme new file mode 100644 index 0000000..2451e11 --- /dev/null +++ b/SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4cead9ac9bf50d06db768647345209098076499b Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 19:47:29 +0100 Subject: [PATCH 39/81] Add tests to travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 13f147b..8c6dbd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,6 @@ script: # - 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 From ae29f6e64276e76352aa4636f77a3de7c064a552 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 19:58:07 +0100 Subject: [PATCH 40/81] Add Travis badge to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b529bc1..0d1683d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # 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) [![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.1-orange.svg) From 1ff1f3cde23593f29c2f60b91e7491003265a1b2 Mon Sep 17 00:00:00 2001 From: radex Date: Wed, 2 Mar 2016 20:09:12 +0100 Subject: [PATCH 41/81] Bump to 1.3.1 --- CHANGELOG.md | 5 +++-- SwiftyTimer.podspec | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0530ab3..5ce67cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -### master +### 1.3.1 (2016-03-02) -- Refactoring (Removed NSTimerActor. Used CFRunLoopTimerCreateWithHandler instead.) #22 @Austinate - Added support for Swift Package Manager +- Refactoring (Removed NSTimerActor. Used CFRunLoopTimerCreateWithHandler instead.) #22 @Austinate +- Added Travis CI ### 1.3.0 (2016-02-29) diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index 6f07d22..6bf590b 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '1.3.0' + s.version = '1.3.1' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' s.homepage = 'https://github.com/radex/SwiftyTimer' From 8cac70158d301b3cc6202bdc6df8ec7d82f27851 Mon Sep 17 00:00:00 2001 From: radex Date: Sun, 10 Apr 2016 13:26:37 +0200 Subject: [PATCH 42/81] =?UTF-8?q?Fix=20Mac=20(Carthage)=20deployment=20tar?= =?UTF-8?q?get=20=E2=80=94=20set=20to=2010.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ SwiftyTimer.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce67cb..ecd1f11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### master + +- Fix Carthage support for Mac (set deployment target to 10.9) + ### 1.3.1 (2016-03-02) - Added support for Swift Package Manager diff --git a/SwiftyTimer.xcodeproj/project.pbxproj b/SwiftyTimer.xcodeproj/project.pbxproj index 2f2a00e..a04be9a 100644 --- a/SwiftyTimer.xcodeproj/project.pbxproj +++ b/SwiftyTimer.xcodeproj/project.pbxproj @@ -453,7 +453,7 @@ INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; @@ -475,7 +475,7 @@ INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer; PRODUCT_NAME = SwiftyTimer; SDKROOT = macosx; From 61335a18f58fd5da59037a7153a33adeb46b3d4f Mon Sep 17 00:00:00 2001 From: radex Date: Sun, 10 Apr 2016 13:44:00 +0200 Subject: [PATCH 43/81] Add a variant of `every` and `new(every:)` that takes a closure with `NSTimer` passed in --- CHANGELOG.md | 1 + Sources/SwiftyTimer.swift | 26 +++++++++++++++++- SwiftyTimerTests/SwiftyTimerTests/main.swift | 29 +++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd1f11..e2fb28f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### master - Fix Carthage support for Mac (set deployment target to 10.9) +- Add a variant of `every` and `new(every:)` that takes a closure with `NSTimer` passed in ### 1.3.1 (2016-03-02) diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index c76605d..e1155c1 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -36,6 +36,7 @@ extension NSTimer { block() } } + /// Create a timer that will call `block` repeatedly in specified time intervals. /// /// - Note: The timer won't fire until it's scheduled on the run loop. @@ -47,7 +48,21 @@ extension NSTimer { block() } } - + + /// Create a timer that will call `block` repeatedly in specified time intervals. + /// (This variant also passes the timer instance to the block) + /// + /// - Note: The timer won't fire until it's scheduled on the run loop. + /// 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) + + @nonobjc public class func new(every interval: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer { + var timer: NSTimer! + timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in + block(timer) + } + return timer + } /// Create and schedule a timer that will call `block` once after the specified time. @@ -65,6 +80,15 @@ extension NSTimer { return 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: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer { + let timer = NSTimer.new(every: interval, block) + timer.start() + return timer + } + /// Schedule this timer on the run loop /// /// By default, the timer is scheduled on the current run loop for the default mode. diff --git a/SwiftyTimerTests/SwiftyTimerTests/main.swift b/SwiftyTimerTests/SwiftyTimerTests/main.swift index e33639e..ff89ed1 100644 --- a/SwiftyTimerTests/SwiftyTimerTests/main.swift +++ b/SwiftyTimerTests/SwiftyTimerTests/main.swift @@ -78,7 +78,34 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func test7() { - NSTimer.after(0.1.seconds, done) + NSTimer.after(0.1.seconds, test8) + } + + func test8() { + var fires = 0 + let timer = NSTimer.new(every: 0.1.seconds) { (timer: NSTimer) in + guard fires <= 1 else { fatalError("should be invalidated") } + defer { fires += 1 } + + if fires == 1 { + timer.invalidate() + self.test9() + } + } + timer.start() + } + + func test9() { + var fires = 0 + NSTimer.every(0.1.seconds) { (timer: NSTimer) in + guard fires <= 1 else { fatalError("should be invalidated") } + defer { fires += 1 } + + if fires == 1 { + timer.invalidate() + self.done() + } + } } func done() { From b5009e9fbae37486bac07008eb12d5a4fc49d616 Mon Sep 17 00:00:00 2001 From: radex Date: Sun, 10 Apr 2016 13:58:29 +0200 Subject: [PATCH 44/81] Improve README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0d1683d..50bb77f 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.1-orange.svg) +![Swift version](https://img.shields.io/badge/swift-2.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. @@ -25,12 +25,10 @@ NSTimer.after(1.minute) { } ``` -SwiftyTimer uses closures instead of target/selector/userInfo. - -You can specify time intervals with intuitive [Ruby on Rails](http://rubyonrails.org)-like helpers: +You can specify time intervals with these intuitive helpers: ```swift -100.milliseconds +100.ms 1.second 2.5.seconds 5.seconds @@ -45,6 +43,8 @@ You can pass method references instead of closures: NSTimer.every(30.seconds, align) ``` +### Manual scheduling + If you want to make a timer object without scheduling, use `new(after:)` and `new(every:)`: ```swift From 4de0130a3b767140b38884b4f3fc39bc41e67dec Mon Sep 17 00:00:00 2001 From: radex Date: Sun, 10 Apr 2016 14:16:18 +0200 Subject: [PATCH 45/81] Document invalidation in repeating timers in Readme --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 50bb77f..03f2c2e 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,20 @@ timer.start() timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode) ``` +### Invalidation + +If you want to invalidate a repeating timer on some condition, you can take an `NSTimer` argument in the closure you pass in: + +```swift +NSTimer.every(5.seconds) { (timer: NSTimer) in + // do something + + if finished { + timer.invalidate() + } +} +``` + ## Installation If you're using CocoaPods, just add this line to your Podfile: From 7d8806e1c4854b876444169890710d09112a1043 Mon Sep 17 00:00:00 2001 From: radex Date: Sun, 10 Apr 2016 14:51:50 +0200 Subject: [PATCH 46/81] Improve documentation --- Sources/SwiftyTimer.swift | 59 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/Sources/SwiftyTimer.swift b/Sources/SwiftyTimer.swift index e1155c1..eb76d3e 100644 --- a/Sources/SwiftyTimer.swift +++ b/Sources/SwiftyTimer.swift @@ -25,6 +25,36 @@ import Foundation extension NSTimer { + +// 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) + 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) + timer.start() + return 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: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer { + let timer = NSTimer.new(every: interval, block) + timer.start() + return timer + } + +// MARK: Create timers without scheduling + /// Create a timer that will call `block` once after the specified time. /// /// - Note: The timer won't fire until it's scheduled on the run loop. @@ -40,7 +70,7 @@ extension NSTimer { /// Create a timer that will call `block` repeatedly in specified time intervals. /// /// - Note: The timer won't fire until it's scheduled on the run loop. - /// Use `NSTimer.after` to create and schedule a timer in one step. + /// 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 { @@ -53,7 +83,7 @@ extension NSTimer { /// (This variant also passes the timer instance to the block) /// /// - Note: The timer won't fire until it's scheduled on the run loop. - /// Use `NSTimer.after` to create and schedule a timer in one step. + /// 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 { @@ -63,31 +93,8 @@ extension NSTimer { } return timer } - - /// 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) - 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) - timer.start() - return 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: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer { - let timer = NSTimer.new(every: interval, block) - timer.start() - return timer - } +// MARK: Manual scheduling /// Schedule this timer on the run loop /// From 3b4f233989dd60dc2dd728659e5bcf750a8c9f2f Mon Sep 17 00:00:00 2001 From: radex Date: Sun, 10 Apr 2016 14:53:34 +0200 Subject: [PATCH 47/81] Ship 1.4.0 --- CHANGELOG.md | 4 ++-- SwiftyTimer.podspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2fb28f..d0dfd64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ -### master +### 1.4.0 (2016-04-10) -- Fix Carthage support for Mac (set deployment target to 10.9) - Add a variant of `every` and `new(every:)` that takes a closure with `NSTimer` passed in +- Fix Carthage support for Mac (set deployment target to 10.9) ### 1.3.1 (2016-03-02) diff --git a/SwiftyTimer.podspec b/SwiftyTimer.podspec index 6bf590b..6c58984 100644 --- a/SwiftyTimer.podspec +++ b/SwiftyTimer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftyTimer' - s.version = '1.3.1' + s.version = '1.4.0' s.license = 'MIT' s.summary = 'Swifty API for NSTimer' s.homepage = 'https://github.com/radex/SwiftyTimer' 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 48/81] 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 49/81] 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 50/81] 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 51/81] 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 52/81] 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 53/81] 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 54/81] 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 55/81] 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 56/81] 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 57/81] 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 58/81] 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 59/81] 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 60/81] 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 61/81] 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 62/81] 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 63/81] 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 64/81] 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 65/81] 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 66/81] 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 67/81] 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 68/81] 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 69/81] 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 70/81] 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 71/81] 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 72/81] 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 73/81] 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 74/81] 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 75/81] 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 76/81] 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 77/81] 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 78/81] 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 79/81] 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 80/81] 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 81/81] 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'