diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..5186d07 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +4.0 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..532bc01 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 刘栋 + +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. diff --git a/README.md b/README.md index ab4bae2..7740be4 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,14 @@ timer.start() ## Installation +CococaPods: + +``` +pod 'SwiftTimer', '~> 2.0' +``` + Carthage: ~~~ github "100mango/SwiftTimer" -~~~ \ No newline at end of file +~~~ diff --git a/Sources/Info-iOS.plist b/Sources/Info-iOS.plist index fbe1e6b..0ae39de 100644 --- a/Sources/Info-iOS.plist +++ b/Sources/Info-iOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Info-macOS.plist b/Sources/Info-macOS.plist index fbe1e6b..0ae39de 100644 --- a/Sources/Info-macOS.plist +++ b/Sources/Info-macOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Info-tvOS.plist b/Sources/Info-tvOS.plist index fbe1e6b..0ae39de 100644 --- a/Sources/Info-tvOS.plist +++ b/Sources/Info-tvOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Info-watchOS.plist b/Sources/Info-watchOS.plist index fbe1e6b..0ae39de 100644 --- a/Sources/Info-watchOS.plist +++ b/Sources/Info-watchOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/SwiftTimer.h b/Sources/SwiftTimer.h index dc270d2..2bfd737 100644 --- a/Sources/SwiftTimer.h +++ b/Sources/SwiftTimer.h @@ -6,7 +6,7 @@ // // -#import +#import //! Project version number for SwiftTimer. FOUNDATION_EXPORT double SwiftTimer_VersionNumber; diff --git a/Sources/SwiftTimer.swift b/Sources/SwiftTimer.swift index 8aff5ef..c51b66e 100644 --- a/Sources/SwiftTimer.swift +++ b/Sources/SwiftTimer.swift @@ -32,9 +32,9 @@ public class SwiftTimer { } if repeats { - internalTimer.scheduleRepeating(deadline: .now() + interval, interval: interval) + internalTimer.schedule(deadline: .now() + interval, repeating: interval) } else { - internalTimer.scheduleOneshot(deadline: .now() + interval) + internalTimer.schedule(deadline: .now() + interval) } } @@ -74,7 +74,7 @@ public class SwiftTimer { public func rescheduleRepeating(interval: DispatchTimeInterval) { if repeats { - internalTimer.scheduleRepeating(deadline: .now() + interval, interval: interval) + internalTimer.schedule(deadline: .now() + interval, repeating: interval) } } @@ -103,7 +103,7 @@ public extension SwiftTimer { let timer = DispatchSource.makeTimerSource(queue: queue) timers[identifier] = timer - timer.scheduleOneshot(deadline: .now() + interval) + timer.schedule(deadline: .now() + interval) timer.setEventHandler { handler() timer.cancel() diff --git a/SwiftTimer.podspec b/SwiftTimer.podspec new file mode 100644 index 0000000..66c96c8 --- /dev/null +++ b/SwiftTimer.podspec @@ -0,0 +1,18 @@ +Pod::Spec.new do |s| + + s.name = "SwiftTimer" + s.version = "2.0" + s.summary = "Simple and Elegant Timer" + s.homepage = "https://github.com/anotheren/SwiftTimer" + s.license = { :type => "MIT" } + s.author = { "liudong" => "liudong.edward@qq.com" } + s.requires_arc = true + s.ios.deployment_target = "8.0" + s.osx.deployment_target = "10.11" + s.watchos.deployment_target = "3.0" + s.tvos.deployment_target = "10.0" + s.source = { :git => "https://github.com/anotheren/SwiftTimer.git", + :tag => s.version } + s.source_files = "Sources/*.swift" + +end diff --git a/SwiftTimer.xcodeproj/project.pbxproj b/SwiftTimer.xcodeproj/project.pbxproj index 3ad0c3e..dde13ce 100644 --- a/SwiftTimer.xcodeproj/project.pbxproj +++ b/SwiftTimer.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + A0B1A44B1F11E2B700677CDB /* SwiftTimer.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SwiftTimer.podspec; sourceTree = ""; }; BF84D1691D6C016500B5B511 /* SwiftTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BF84D16C1D6C016500B5B511 /* SwiftTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SwiftTimer.h; path = Sources/SwiftTimer.h; sourceTree = ""; }; BF84D1771D6C01A600B5B511 /* SwiftTimer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftTimer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -89,6 +90,7 @@ BF84D15D1D6C010700B5B511 = { isa = PBXGroup; children = ( + A0B1A44B1F11E2B700677CDB /* SwiftTimer.podspec */, BF84D1AF1D6C033000B5B511 /* Sources */, BF84D1BE1D6C0F1600B5B511 /* SwiftTimer iOSTests */, BF84D16A1D6C016500B5B511 /* Products */, @@ -264,10 +266,11 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0910; TargetAttributes = { BF84D1681D6C016500B5B511 = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; }; BF84D1761D6C01A600B5B511 = { @@ -404,12 +407,62 @@ BF84D1621D6C010700B5B511 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + 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_LITERAL_CONVERSION = YES; + 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; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; }; name = Debug; }; BF84D1631D6C010700B5B511 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + 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_LITERAL_CONVERSION = YES; + 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; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; }; name = Release; }; @@ -417,6 +470,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -435,7 +489,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; @@ -471,7 +525,8 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -482,6 +537,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -500,7 +556,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -528,7 +584,8 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -663,6 +720,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -727,6 +785,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -784,6 +843,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -849,6 +909,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1024,6 +1085,7 @@ BF84D1711D6C016500B5B511 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; BF84D17C1D6C01A600B5B511 /* Build configuration list for PBXNativeTarget "SwiftTimer watchOS" */ = { isa = XCConfigurationList; @@ -1032,6 +1094,7 @@ BF84D17E1D6C01A600B5B511 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; BF84D1891D6C01C000B5B511 /* Build configuration list for PBXNativeTarget "SwiftTimer tvOS" */ = { isa = XCConfigurationList; @@ -1040,6 +1103,7 @@ BF84D18B1D6C01C000B5B511 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; BF84D1961D6C01DD00B5B511 /* Build configuration list for PBXNativeTarget "SwiftTimer macOS" */ = { isa = XCConfigurationList; @@ -1048,6 +1112,7 @@ BF84D1981D6C01DD00B5B511 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; BF84D1C51D6C0F1600B5B511 /* Build configuration list for PBXNativeTarget "SwiftTimer iOSTests" */ = { isa = XCConfigurationList; @@ -1056,6 +1121,7 @@ BF84D1C71D6C0F1600B5B511 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/SwiftTimer.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/SwiftTimer.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..3ddf867 --- /dev/null +++ b/SwiftTimer.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + BuildSystemType + Latest + + diff --git a/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer iOS.xcscheme b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer iOS.xcscheme index e79f6fa..70be071 100644 --- a/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer iOS.xcscheme +++ b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer iOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer macOS.xcscheme b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer macOS.xcscheme new file mode 100644 index 0000000..b2b8d89 --- /dev/null +++ b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer macOS.xcscheme @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer tvOS.xcscheme b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer tvOS.xcscheme index e01fe57..b85710c 100644 --- a/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer tvOS.xcscheme +++ b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer tvOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer watchOS.xcscheme b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer watchOS.xcscheme index 3c9f2a4..99638fb 100644 --- a/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer watchOS.xcscheme +++ b/SwiftTimer.xcodeproj/xcshareddata/xcschemes/SwiftTimer watchOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/SwiftTimer.xcworkspace/contents.xcworkspacedata b/SwiftTimer.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index c604831..0000000 --- a/SwiftTimer.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - -