From 9e5e51bf3081c97f09acd4384cfbc78da12bcc81 Mon Sep 17 00:00:00 2001 From: Keishi Suzuki Date: Wed, 26 Sep 2018 18:52:53 +0900 Subject: [PATCH 1/5] swift5 and swift package manager version --- .../contents.xcworkspacedata | 7 ++ CountdownLabel.podspec | 14 --- CountdownLabel.xcodeproj/project.pbxproj | 114 ++---------------- CountdownLabel/CountdownLabel.swift | 2 +- CountdownLabel/LTMorphingLabel/LTEasing.swift | 4 +- Package.swift | 28 +++++ Sources/CountdownLabel/CountdownLabel.swift | 3 + .../CountdownLabelTests.swift | 15 +++ .../CountdownLabelTests/XCTestManifests.swift | 9 ++ Tests/LinuxMain.swift | 7 ++ 10 files changed, 81 insertions(+), 122 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata delete mode 100644 CountdownLabel.podspec create mode 100644 Package.swift create mode 100644 Sources/CountdownLabel/CountdownLabel.swift create mode 100644 Tests/CountdownLabelTests/CountdownLabelTests.swift create mode 100644 Tests/CountdownLabelTests/XCTestManifests.swift create mode 100644 Tests/LinuxMain.swift diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CountdownLabel.podspec b/CountdownLabel.podspec deleted file mode 100644 index e228404..0000000 --- a/CountdownLabel.podspec +++ /dev/null @@ -1,14 +0,0 @@ -Pod::Spec.new do |s| - s.name = "CountdownLabel" - s.version = '4.0.0' - s.summary = 'Simple countdown UILabel with morphing animation, and some useful function.' - s.homepage = "https://github.com/suzuki-0000/CountdownLabel" - s.license = { :type => "MIT", :file => "LICENSE" } - s.author = { "suzuki_keishi" => "keishi.1983@gmail.com" } - s.source = { :git => "https://github.com/suzuki-0000/CountdownLabel.git", :tag => s.version } - s.platform = :ios, "8.2" - s.source_files = 'CountdownLabel/*.swift' - s.source_files = 'CountdownLabel/**/*.swift' - s.requires_arc = true - s.frameworks = "UIKit" -end diff --git a/CountdownLabel.xcodeproj/project.pbxproj b/CountdownLabel.xcodeproj/project.pbxproj index 38c9849..0f70810 100644 --- a/CountdownLabel.xcodeproj/project.pbxproj +++ b/CountdownLabel.xcodeproj/project.pbxproj @@ -22,21 +22,8 @@ 764D994C1F87830200204ED2 /* LTCharacterDiffResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 764D992A1F877FF500204ED2 /* LTCharacterDiffResult.swift */; }; 892106D41C3CF4140007CDEC /* CountdownLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = 892106D31C3CF4140007CDEC /* CountdownLabel.h */; settings = {ATTRIBUTES = (Public, ); }; }; 892107001C3CF4490007CDEC /* CountdownLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 892106FF1C3CF4490007CDEC /* CountdownLabel.swift */; }; - 8999B51E1C4F2F7200C46F10 /* CountdownLabelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8999B51D1C4F2F7200C46F10 /* CountdownLabelTests.swift */; }; - 8999B5201C4F2F7200C46F10 /* CountdownLabel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 892106D01C3CF4140007CDEC /* CountdownLabel.framework */; }; - 8999B5271C4F2F8700C46F10 /* StoryboardTests.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8999B5261C4F2F8700C46F10 /* StoryboardTests.storyboard */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 8999B5211C4F2F7200C46F10 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 892106C71C3CF4140007CDEC /* Project object */; - proxyType = 1; - remoteGlobalIDString = 892106CF1C3CF4140007CDEC; - remoteInfo = CountdownLabel; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXFileReference section */ 764D992A1F877FF500204ED2 /* LTCharacterDiffResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LTCharacterDiffResult.swift; sourceTree = ""; }; 764D992B1F877FF500204ED2 /* LTCharacterLimbo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LTCharacterLimbo.swift; sourceTree = ""; }; @@ -60,7 +47,6 @@ 892106D31C3CF4140007CDEC /* CountdownLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CountdownLabel.h; sourceTree = ""; }; 892106D51C3CF4140007CDEC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 892106FF1C3CF4490007CDEC /* CountdownLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CountdownLabel.swift; sourceTree = ""; }; - 8999B51B1C4F2F7200C46F10 /* CountdownLabelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CountdownLabelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8999B51D1C4F2F7200C46F10 /* CountdownLabelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountdownLabelTests.swift; sourceTree = ""; }; 8999B51F1C4F2F7200C46F10 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8999B5261C4F2F8700C46F10 /* StoryboardTests.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = StoryboardTests.storyboard; sourceTree = ""; }; @@ -74,14 +60,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8999B5181C4F2F7200C46F10 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8999B5201C4F2F7200C46F10 /* CountdownLabel.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -131,7 +109,6 @@ isa = PBXGroup; children = ( 892106D01C3CF4140007CDEC /* CountdownLabel.framework */, - 8999B51B1C4F2F7200C46F10 /* CountdownLabelTests.xctest */, ); name = Products; sourceTree = ""; @@ -190,24 +167,6 @@ productReference = 892106D01C3CF4140007CDEC /* CountdownLabel.framework */; productType = "com.apple.product-type.framework"; }; - 8999B51A1C4F2F7200C46F10 /* CountdownLabelTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 8999B5231C4F2F7200C46F10 /* Build configuration list for PBXNativeTarget "CountdownLabelTests" */; - buildPhases = ( - 8999B5171C4F2F7200C46F10 /* Sources */, - 8999B5181C4F2F7200C46F10 /* Frameworks */, - 8999B5191C4F2F7200C46F10 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 8999B5221C4F2F7200C46F10 /* PBXTargetDependency */, - ); - name = CountdownLabelTests; - productName = CountdownLabelTests; - productReference = 8999B51B1C4F2F7200C46F10 /* CountdownLabelTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -222,10 +181,6 @@ CreatedOnToolsVersion = 7.2; LastSwiftMigration = 0800; }; - 8999B51A1C4F2F7200C46F10 = { - CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0830; - }; }; }; buildConfigurationList = 892106CA1C3CF4140007CDEC /* Build configuration list for PBXProject "CountdownLabel" */; @@ -233,6 +188,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 892106C61C3CF4140007CDEC; @@ -241,7 +197,6 @@ projectRoot = ""; targets = ( 892106CF1C3CF4140007CDEC /* CountdownLabel */, - 8999B51A1C4F2F7200C46F10 /* CountdownLabelTests */, ); }; /* End PBXProject section */ @@ -254,14 +209,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8999B5191C4F2F7200C46F10 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8999B5271C4F2F8700C46F10 /* StoryboardTests.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -302,24 +249,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8999B5171C4F2F7200C46F10 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8999B51E1C4F2F7200C46F10 /* CountdownLabelTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 8999B5221C4F2F7200C46F10 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 892106CF1C3CF4140007CDEC /* CountdownLabel */; - targetProxy = 8999B5211C4F2F7200C46F10 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin XCBuildConfiguration section */ 892106D61C3CF4140007CDEC /* Debug */ = { isa = XCBuildConfiguration; @@ -443,13 +374,15 @@ ); INFOPLIST_FILE = CountdownLabel/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.keishi.suzuki.CountdownLabel; PRODUCT_NAME = CountdownLabel; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -469,34 +402,14 @@ ); INFOPLIST_FILE = CountdownLabel/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.keishi.suzuki.CountdownLabel; PRODUCT_NAME = CountdownLabel; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; - }; - name = Release; - }; - 8999B5241C4F2F7200C46F10 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = CountdownLabelTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.keishi.suzuki.CountdownLabelTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; - }; - name = Debug; - }; - 8999B5251C4F2F7200C46F10 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = CountdownLabelTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.keishi.suzuki.CountdownLabelTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SUPPORTS_MACCATALYST = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; @@ -521,15 +434,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 8999B5231C4F2F7200C46F10 /* Build configuration list for PBXNativeTarget "CountdownLabelTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 8999B5241C4F2F7200C46F10 /* Debug */, - 8999B5251C4F2F7200C46F10 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 892106C71C3CF4140007CDEC /* Project object */; diff --git a/CountdownLabel/CountdownLabel.swift b/CountdownLabel/CountdownLabel.swift index 7314dab..e230738 100644 --- a/CountdownLabel/CountdownLabel.swift +++ b/CountdownLabel/CountdownLabel.swift @@ -33,7 +33,7 @@ public class CountdownLabel: LTMorphingLabel { public var dateFormatter: DateFormatter { let df = DateFormatter() df.locale = Locale(identifier: "en_US_POSIX") - df.timeZone = NSTimeZone(name: "GMT") as TimeZone! + df.timeZone = TimeZone(identifier: "GMT") df.dateFormat = timeFormat return df } diff --git a/CountdownLabel/LTMorphingLabel/LTEasing.swift b/CountdownLabel/LTMorphingLabel/LTEasing.swift index 090d37d..62ed49f 100644 --- a/CountdownLabel/LTMorphingLabel/LTEasing.swift +++ b/CountdownLabel/LTMorphingLabel/LTEasing.swift @@ -18,13 +18,13 @@ public struct LTEasing { public static func easeOutQuint(_ t: Float, _ b: Float, _ c: Float, _ d: Float = 1.0) -> Float { return { - return c * ($0 * $0 * $0 * $0 * $0 + 1.0) + b + return c * (pow($0, 5) + 1.0) + b }(t / d - 1.0) } public static func easeInQuint(_ t: Float, _ b: Float, _ c: Float, _ d: Float = 1.0) -> Float { return { - return c * $0 * $0 * $0 * $0 * $0 + b + return (c * pow($0, 5) + b) }(t / d) } diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..1e9b79d --- /dev/null +++ b/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "CountdownLabel", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "CountdownLabel", + targets: ["CountdownLabel"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "CountdownLabel", + dependencies: []), + .testTarget( + name: "CountdownLabelTests", + dependencies: ["CountdownLabel"]), + ] +) diff --git a/Sources/CountdownLabel/CountdownLabel.swift b/Sources/CountdownLabel/CountdownLabel.swift new file mode 100644 index 0000000..2bf0182 --- /dev/null +++ b/Sources/CountdownLabel/CountdownLabel.swift @@ -0,0 +1,3 @@ +struct CountdownLabel { + var text = "Hello, World!" +} diff --git a/Tests/CountdownLabelTests/CountdownLabelTests.swift b/Tests/CountdownLabelTests/CountdownLabelTests.swift new file mode 100644 index 0000000..5ef2a41 --- /dev/null +++ b/Tests/CountdownLabelTests/CountdownLabelTests.swift @@ -0,0 +1,15 @@ +import XCTest +@testable import CountdownLabel + +final class CountdownLabelTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(CountdownLabel().text, "Hello, World!") + } + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/Tests/CountdownLabelTests/XCTestManifests.swift b/Tests/CountdownLabelTests/XCTestManifests.swift new file mode 100644 index 0000000..8b8d046 --- /dev/null +++ b/Tests/CountdownLabelTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(CountdownLabelTests.allTests), + ] +} +#endif diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..615f299 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import CountdownLabelTests + +var tests = [XCTestCaseEntry]() +tests += CountdownLabelTests.allTests() +XCTMain(tests) From 9f96d7b47dea3f475982d440ddc276e44a46ffb5 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 14 Apr 2021 12:04:24 +0900 Subject: [PATCH 2/5] bug fixed --- CountdownLabel.xcodeproj/project.pbxproj | 3 +- CountdownLabel/CountdownLabel.swift | 402 ----------------- Package.swift | 7 +- .../CountdownLabel}/CountdownLabel.h | 0 Sources/CountdownLabel/CountdownLabel.swift | 403 +++++++++++++++++- .../CountdownLabel}/Info.plist | 0 .../LTMorphingLabel/Info.plist | 0 .../LTCharacterDiffResult.swift | 0 .../LTMorphingLabel/LTCharacterLimbo.swift | 0 .../LTMorphingLabel/LTEasing.swift | 0 .../LTMorphingLabel/LTEmitterView.swift | 0 .../LTMorphingLabel/LTMorphingEffect.swift | 0 .../LTMorphingLabel+Anvil.swift | 0 .../LTMorphingLabel+Burn.swift | 0 .../LTMorphingLabel+Evaporate.swift | 0 .../LTMorphingLabel+Fall.swift | 0 .../LTMorphingLabel+Pixelate.swift | 0 .../LTMorphingLabel+Sparkle.swift | 0 .../LTMorphingLabel/LTMorphingLabel.h | 0 .../LTMorphingLabel/LTMorphingLabel.swift | 0 .../LTMorphingLabel/LTStringDiffResult.swift | 0 .../LTMorphingLabel/Particles/Fire.png | Bin .../LTMorphingLabel/Particles/Fragment.png | Bin .../LTMorphingLabel/Particles/Smoke.png | Bin .../LTMorphingLabel/Particles/Sparkle.png | Bin .../LTMorphingLabel/tvOS-Info.plist | 0 26 files changed, 406 insertions(+), 409 deletions(-) delete mode 100644 CountdownLabel/CountdownLabel.swift rename {CountdownLabel => Sources/CountdownLabel}/CountdownLabel.h (100%) rename {CountdownLabel => Sources/CountdownLabel}/Info.plist (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/Info.plist (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTCharacterDiffResult.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTCharacterLimbo.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTEasing.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTEmitterView.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingEffect.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel+Anvil.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel+Burn.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel+Evaporate.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel+Fall.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel+Pixelate.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel+Sparkle.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel.h (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTMorphingLabel.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/LTStringDiffResult.swift (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/Particles/Fire.png (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/Particles/Fragment.png (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/Particles/Smoke.png (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/Particles/Sparkle.png (100%) rename {CountdownLabel => Sources/CountdownLabel}/LTMorphingLabel/tvOS-Info.plist (100%) diff --git a/CountdownLabel.xcodeproj/project.pbxproj b/CountdownLabel.xcodeproj/project.pbxproj index 0f70810..6f48b94 100644 --- a/CountdownLabel.xcodeproj/project.pbxproj +++ b/CountdownLabel.xcodeproj/project.pbxproj @@ -121,7 +121,8 @@ 892106FF1C3CF4490007CDEC /* CountdownLabel.swift */, 892106D51C3CF4140007CDEC /* Info.plist */, ); - path = CountdownLabel; + name = CountdownLabel; + path = Sources/CountdownLabel; sourceTree = ""; }; 8999B51C1C4F2F7200C46F10 /* CountdownLabelTests */ = { diff --git a/CountdownLabel/CountdownLabel.swift b/CountdownLabel/CountdownLabel.swift deleted file mode 100644 index e230738..0000000 --- a/CountdownLabel/CountdownLabel.swift +++ /dev/null @@ -1,402 +0,0 @@ -// -// CountdownLabel.swift -// CountdownLabel -// -// Created by suzuki keishi on 2016/01/06. -// Copyright © 2016 suzuki_keishi. All rights reserved. -// - -import UIKit - -@objc public protocol CountdownLabelDelegate { - @objc optional func countdownStarted() - @objc optional func countdownPaused() - @objc optional func countdownFinished() - @objc optional func countdownCancelled() - @objc optional func countingAt(timeCounted: TimeInterval, timeRemaining: TimeInterval) - -} -extension TimeInterval { - var int: Int { - return Int(self) - } -} - -public class CountdownLabel: LTMorphingLabel { - - public typealias CountdownCompletion = () -> ()? - public typealias CountdownExecution = () -> () - internal let defaultFireInterval = 1.0 - internal let date1970 = NSDate(timeIntervalSince1970: 0) - - // conputed property - public var dateFormatter: DateFormatter { - let df = DateFormatter() - df.locale = Locale(identifier: "en_US_POSIX") - df.timeZone = TimeZone(identifier: "GMT") - df.dateFormat = timeFormat - return df - } - - public var timeCounted: TimeInterval { - let timeCounted = NSDate().timeIntervalSince(fromDate as Date) - return round(timeCounted < 0 ? 0 : timeCounted) - } - - public var timeRemaining: TimeInterval { - return round(currentTime) - timeCounted - } - - public var isPaused: Bool { - return paused - } - - public var isCounting: Bool { - return counting - } - - public var isFinished: Bool { - return finished - } - - public weak var countdownDelegate: CountdownLabelDelegate? - - // user settings - public var animationType: CountdownEffect? { - didSet { - if let effect = animationType?.toLTMorphing() { - morphingEffect = effect - morphingEnabled = true - } else { - morphingEnabled = false - } - } - } - public var timeFormat = "HH:mm:ss" - public var thens = [TimeInterval: CountdownExecution]() - public var countdownAttributedText: CountdownAttributedText! { - didSet { - range = (countdownAttributedText.text as NSString).range(of: countdownAttributedText.replacement) - } - } - - internal var completion: CountdownCompletion? - internal var fromDate: NSDate = NSDate() - internal var currentDate: NSDate = NSDate() - internal var currentTime: TimeInterval = 0 - internal var diffDate: NSDate! - internal var targetTime: TimeInterval = 0 - internal var pausedDate: NSDate! - internal var range: NSRange! - internal var timer: Timer! - - internal var counting: Bool = false - internal var endOfTimer: Bool { - return timeCounted >= currentTime - } - internal var finished: Bool = false { - didSet { - if finished { - paused = false - counting = false - } - } - } - internal var paused: Bool = false - - // MARK: - Initialize - public required init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - setup() - } - - public override required init(frame: CGRect) { - super.init(frame: frame) - setup() - } - - public convenience init(frame: CGRect, minutes: TimeInterval) { - self.init(frame: frame) - setCountDownTime(minutes: minutes) - } - - public convenience init(frame: CGRect, date: NSDate) { - self.init(frame: frame) - setCountDownDate(targetDate: date) - } - - public convenience init(frame: CGRect, fromDate: NSDate, targetDate: NSDate) { - self.init(frame: frame) - setCountDownDate(fromDate: fromDate, targetDate: targetDate) - } - - deinit { - dispose() - } - - // MARK: - Setter Methods - public func setCountDownTime(minutes: TimeInterval) { - setCountDownTime(fromDate: NSDate(), minutes: minutes) - } - - public func setCountDownTime(fromDate: NSDate, minutes: TimeInterval) { - self.fromDate = fromDate - - targetTime = minutes - currentTime = minutes - diffDate = date1970.addingTimeInterval(minutes) - - updateLabel() - } - - public func setCountDownDate(targetDate: NSDate) { - setCountDownDate(fromDate: NSDate(), targetDate: targetDate) - } - - public func setCountDownDate(fromDate: NSDate, targetDate: NSDate) { - self.fromDate = fromDate - - targetTime = targetDate.timeIntervalSince(fromDate as Date) - currentTime = targetDate.timeIntervalSince(fromDate as Date) - diffDate = date1970.addingTimeInterval(targetTime) - - updateLabel() - } - - // MARK: - Update - @objc func updateLabel() { - // delegate - countdownDelegate?.countingAt?(timeCounted: timeCounted, timeRemaining: timeRemaining) - - // then function execute if needed - thens.forEach { k, v in - if k.int == timeRemaining.int { - v() - thens[k] = nil - } - } - - // update text - updateText() - - // if end of timer - if endOfTimer { - text = dateFormatter.string(from: date1970.addingTimeInterval(0) as Date) - countdownDelegate?.countdownFinished?() - dispose() - completion?() - } - } -} - -// MARK: - Public -extension CountdownLabel { - public func start(completion: ( () -> () )? = nil) { - if !isPaused { - // current date should be setted at the time of the counter's starting, or the time will be wrong (just a few seconds) after the first time of pausing. - currentDate = NSDate() - } - - // pause status check - updatePauseStatusIfNeeded() - - // create timer - updateTimer() - - // fire! - timer.fire() - - // set completion if needed - completion?() - - // set delegate - countdownDelegate?.countdownStarted?() - } - - public func pause(completion: (() -> ())? = nil) { - if paused { - return - } - - // invalidate timer - disposeTimer() - - // stop counting - counting = false - paused = true - - // reset - pausedDate = NSDate() - - // set completion if needed - completion?() - - // set delegate - countdownDelegate?.countdownPaused?() - } - - public func cancel(completion: (() -> ())? = nil) { - text = dateFormatter.string(from: date1970.addingTimeInterval(0) as Date) - dispose() - - // set completion if needed - completion?() - - // set delegate - countdownDelegate?.countdownCancelled?() - } - - public func addTime(time: TimeInterval) { - currentTime = time + currentTime - diffDate = date1970.addingTimeInterval(currentTime) - - updateLabel() - } - - @discardableResult - public func then(targetTime: TimeInterval, completion: @escaping () -> ()) -> Self { - let t = targetTime - (targetTime - targetTime) - guard t > 0 else { - return self - } - - thens[t] = completion - return self - } -} - -// MARK: - private -extension CountdownLabel { - func setup() { - morphingEnabled = false - } - - func updateText() { - guard diffDate != nil else { return } - - let date = diffDate.addingTimeInterval(round(timeCounted * -1)) as Date - // if time is before start - let formattedText = timeCounted < 0 - ? dateFormatter.string(from: date1970.addingTimeInterval(0) as Date) - : self.surplusTime(date) - - if let countdownAttributedText = countdownAttributedText { - let attrTextInRange = NSAttributedString(string: formattedText, attributes: countdownAttributedText.attributes) - let attributedString = NSMutableAttributedString(string: countdownAttributedText.text) - attributedString.replaceCharacters(in: range, with: attrTextInRange) - - attributedText = attributedString - text = attributedString.string - } else { - text = formattedText - } - setNeedsDisplay() - } - - //fix one day bug - func surplusTime(_ to1970Date: Date) -> String { - let calendar = Calendar.init(identifier: .gregorian); - var labelText = timeFormat; - let comp = calendar.dateComponents([.day, .hour, .minute, .second], from: date1970 as Date, to: to1970Date) - - if let day = comp.day ,let _ = timeFormat.range(of: "dd"){ - labelText = labelText.replacingOccurrences(of: "dd", with: String.init(format: "%02ld", day)) - } - if let hour = comp.hour ,let _ = timeFormat.range(of: "hh"){ - labelText = labelText.replacingOccurrences(of: "hh", with: String.init(format: "%02ld", hour)) - } - if let hour = comp.hour ,let _ = timeFormat.range(of: "HH"){ - labelText = labelText.replacingOccurrences(of: "HH", with: String.init(format: "%02ld", hour)) - } - if let minute = comp.minute ,let _ = timeFormat.range(of: "mm"){ - labelText = labelText.replacingOccurrences(of: "mm", with: String.init(format: "%02ld", minute)) - } - if let second = comp.second ,let _ = timeFormat.range(of: "ss"){ - labelText = labelText.replacingOccurrences(of: "ss", with: String.init(format: "%02ld", second)) - } - return labelText - } - - func updatePauseStatusIfNeeded() { - guard paused else { - return - } - // change date - let pastedTime = pausedDate.timeIntervalSince(currentDate as Date) - currentDate = NSDate().addingTimeInterval(-pastedTime) - fromDate = currentDate - - // reset pause - pausedDate = nil - paused = false - } - - func updateTimer() { - disposeTimer() - - // create - timer = Timer.scheduledTimer(timeInterval: defaultFireInterval, - target: self, - selector: #selector(updateLabel), - userInfo: nil, - repeats: true) - - // register to NSrunloop - RunLoop.current.add(timer, forMode: RunLoop.Mode.common) - counting = true - } - - func disposeTimer() { - if timer != nil { - timer.invalidate() - timer = nil - } - } - - func dispose() { - // reset - pausedDate = nil - - // invalidate timer - disposeTimer() - - // stop counting - finished = true - } -} - -public enum CountdownEffect { - case Anvil - case Burn - case Evaporate - case Fall - case None - case Pixelate - case Scale - case Sparkle - - func toLTMorphing() -> LTMorphingEffect? { - switch self { - case .Anvil : return .anvil - case .Burn : return .burn - case .Evaporate : return .evaporate - case .Fall : return .fall - case .None : return nil - case .Pixelate : return .pixelate - case .Scale : return .scale - case .Sparkle : return .sparkle - } - } -} - -public class CountdownAttributedText: NSObject { - internal let text: String - internal let replacement: String - internal let attributes: [NSAttributedString.Key: Any]? - - public init(text: String, replacement: String, attributes: [NSAttributedString.Key: Any]? = nil) { - self.text = text - self.replacement = replacement - self.attributes = attributes - } -} diff --git a/Package.swift b/Package.swift index 1e9b79d..5bc24b0 100644 --- a/Package.swift +++ b/Package.swift @@ -5,6 +5,7 @@ import PackageDescription let package = Package( name: "CountdownLabel", + platforms: [.iOS(.v11)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( @@ -20,9 +21,7 @@ let package = Package( // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "CountdownLabel", - dependencies: []), - .testTarget( - name: "CountdownLabelTests", - dependencies: ["CountdownLabel"]), + dependencies: []) + ] ) diff --git a/CountdownLabel/CountdownLabel.h b/Sources/CountdownLabel/CountdownLabel.h similarity index 100% rename from CountdownLabel/CountdownLabel.h rename to Sources/CountdownLabel/CountdownLabel.h diff --git a/Sources/CountdownLabel/CountdownLabel.swift b/Sources/CountdownLabel/CountdownLabel.swift index 2bf0182..e230738 100644 --- a/Sources/CountdownLabel/CountdownLabel.swift +++ b/Sources/CountdownLabel/CountdownLabel.swift @@ -1,3 +1,402 @@ -struct CountdownLabel { - var text = "Hello, World!" +// +// CountdownLabel.swift +// CountdownLabel +// +// Created by suzuki keishi on 2016/01/06. +// Copyright © 2016 suzuki_keishi. All rights reserved. +// + +import UIKit + +@objc public protocol CountdownLabelDelegate { + @objc optional func countdownStarted() + @objc optional func countdownPaused() + @objc optional func countdownFinished() + @objc optional func countdownCancelled() + @objc optional func countingAt(timeCounted: TimeInterval, timeRemaining: TimeInterval) + +} +extension TimeInterval { + var int: Int { + return Int(self) + } +} + +public class CountdownLabel: LTMorphingLabel { + + public typealias CountdownCompletion = () -> ()? + public typealias CountdownExecution = () -> () + internal let defaultFireInterval = 1.0 + internal let date1970 = NSDate(timeIntervalSince1970: 0) + + // conputed property + public var dateFormatter: DateFormatter { + let df = DateFormatter() + df.locale = Locale(identifier: "en_US_POSIX") + df.timeZone = TimeZone(identifier: "GMT") + df.dateFormat = timeFormat + return df + } + + public var timeCounted: TimeInterval { + let timeCounted = NSDate().timeIntervalSince(fromDate as Date) + return round(timeCounted < 0 ? 0 : timeCounted) + } + + public var timeRemaining: TimeInterval { + return round(currentTime) - timeCounted + } + + public var isPaused: Bool { + return paused + } + + public var isCounting: Bool { + return counting + } + + public var isFinished: Bool { + return finished + } + + public weak var countdownDelegate: CountdownLabelDelegate? + + // user settings + public var animationType: CountdownEffect? { + didSet { + if let effect = animationType?.toLTMorphing() { + morphingEffect = effect + morphingEnabled = true + } else { + morphingEnabled = false + } + } + } + public var timeFormat = "HH:mm:ss" + public var thens = [TimeInterval: CountdownExecution]() + public var countdownAttributedText: CountdownAttributedText! { + didSet { + range = (countdownAttributedText.text as NSString).range(of: countdownAttributedText.replacement) + } + } + + internal var completion: CountdownCompletion? + internal var fromDate: NSDate = NSDate() + internal var currentDate: NSDate = NSDate() + internal var currentTime: TimeInterval = 0 + internal var diffDate: NSDate! + internal var targetTime: TimeInterval = 0 + internal var pausedDate: NSDate! + internal var range: NSRange! + internal var timer: Timer! + + internal var counting: Bool = false + internal var endOfTimer: Bool { + return timeCounted >= currentTime + } + internal var finished: Bool = false { + didSet { + if finished { + paused = false + counting = false + } + } + } + internal var paused: Bool = false + + // MARK: - Initialize + public required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup() + } + + public override required init(frame: CGRect) { + super.init(frame: frame) + setup() + } + + public convenience init(frame: CGRect, minutes: TimeInterval) { + self.init(frame: frame) + setCountDownTime(minutes: minutes) + } + + public convenience init(frame: CGRect, date: NSDate) { + self.init(frame: frame) + setCountDownDate(targetDate: date) + } + + public convenience init(frame: CGRect, fromDate: NSDate, targetDate: NSDate) { + self.init(frame: frame) + setCountDownDate(fromDate: fromDate, targetDate: targetDate) + } + + deinit { + dispose() + } + + // MARK: - Setter Methods + public func setCountDownTime(minutes: TimeInterval) { + setCountDownTime(fromDate: NSDate(), minutes: minutes) + } + + public func setCountDownTime(fromDate: NSDate, minutes: TimeInterval) { + self.fromDate = fromDate + + targetTime = minutes + currentTime = minutes + diffDate = date1970.addingTimeInterval(minutes) + + updateLabel() + } + + public func setCountDownDate(targetDate: NSDate) { + setCountDownDate(fromDate: NSDate(), targetDate: targetDate) + } + + public func setCountDownDate(fromDate: NSDate, targetDate: NSDate) { + self.fromDate = fromDate + + targetTime = targetDate.timeIntervalSince(fromDate as Date) + currentTime = targetDate.timeIntervalSince(fromDate as Date) + diffDate = date1970.addingTimeInterval(targetTime) + + updateLabel() + } + + // MARK: - Update + @objc func updateLabel() { + // delegate + countdownDelegate?.countingAt?(timeCounted: timeCounted, timeRemaining: timeRemaining) + + // then function execute if needed + thens.forEach { k, v in + if k.int == timeRemaining.int { + v() + thens[k] = nil + } + } + + // update text + updateText() + + // if end of timer + if endOfTimer { + text = dateFormatter.string(from: date1970.addingTimeInterval(0) as Date) + countdownDelegate?.countdownFinished?() + dispose() + completion?() + } + } +} + +// MARK: - Public +extension CountdownLabel { + public func start(completion: ( () -> () )? = nil) { + if !isPaused { + // current date should be setted at the time of the counter's starting, or the time will be wrong (just a few seconds) after the first time of pausing. + currentDate = NSDate() + } + + // pause status check + updatePauseStatusIfNeeded() + + // create timer + updateTimer() + + // fire! + timer.fire() + + // set completion if needed + completion?() + + // set delegate + countdownDelegate?.countdownStarted?() + } + + public func pause(completion: (() -> ())? = nil) { + if paused { + return + } + + // invalidate timer + disposeTimer() + + // stop counting + counting = false + paused = true + + // reset + pausedDate = NSDate() + + // set completion if needed + completion?() + + // set delegate + countdownDelegate?.countdownPaused?() + } + + public func cancel(completion: (() -> ())? = nil) { + text = dateFormatter.string(from: date1970.addingTimeInterval(0) as Date) + dispose() + + // set completion if needed + completion?() + + // set delegate + countdownDelegate?.countdownCancelled?() + } + + public func addTime(time: TimeInterval) { + currentTime = time + currentTime + diffDate = date1970.addingTimeInterval(currentTime) + + updateLabel() + } + + @discardableResult + public func then(targetTime: TimeInterval, completion: @escaping () -> ()) -> Self { + let t = targetTime - (targetTime - targetTime) + guard t > 0 else { + return self + } + + thens[t] = completion + return self + } +} + +// MARK: - private +extension CountdownLabel { + func setup() { + morphingEnabled = false + } + + func updateText() { + guard diffDate != nil else { return } + + let date = diffDate.addingTimeInterval(round(timeCounted * -1)) as Date + // if time is before start + let formattedText = timeCounted < 0 + ? dateFormatter.string(from: date1970.addingTimeInterval(0) as Date) + : self.surplusTime(date) + + if let countdownAttributedText = countdownAttributedText { + let attrTextInRange = NSAttributedString(string: formattedText, attributes: countdownAttributedText.attributes) + let attributedString = NSMutableAttributedString(string: countdownAttributedText.text) + attributedString.replaceCharacters(in: range, with: attrTextInRange) + + attributedText = attributedString + text = attributedString.string + } else { + text = formattedText + } + setNeedsDisplay() + } + + //fix one day bug + func surplusTime(_ to1970Date: Date) -> String { + let calendar = Calendar.init(identifier: .gregorian); + var labelText = timeFormat; + let comp = calendar.dateComponents([.day, .hour, .minute, .second], from: date1970 as Date, to: to1970Date) + + if let day = comp.day ,let _ = timeFormat.range(of: "dd"){ + labelText = labelText.replacingOccurrences(of: "dd", with: String.init(format: "%02ld", day)) + } + if let hour = comp.hour ,let _ = timeFormat.range(of: "hh"){ + labelText = labelText.replacingOccurrences(of: "hh", with: String.init(format: "%02ld", hour)) + } + if let hour = comp.hour ,let _ = timeFormat.range(of: "HH"){ + labelText = labelText.replacingOccurrences(of: "HH", with: String.init(format: "%02ld", hour)) + } + if let minute = comp.minute ,let _ = timeFormat.range(of: "mm"){ + labelText = labelText.replacingOccurrences(of: "mm", with: String.init(format: "%02ld", minute)) + } + if let second = comp.second ,let _ = timeFormat.range(of: "ss"){ + labelText = labelText.replacingOccurrences(of: "ss", with: String.init(format: "%02ld", second)) + } + return labelText + } + + func updatePauseStatusIfNeeded() { + guard paused else { + return + } + // change date + let pastedTime = pausedDate.timeIntervalSince(currentDate as Date) + currentDate = NSDate().addingTimeInterval(-pastedTime) + fromDate = currentDate + + // reset pause + pausedDate = nil + paused = false + } + + func updateTimer() { + disposeTimer() + + // create + timer = Timer.scheduledTimer(timeInterval: defaultFireInterval, + target: self, + selector: #selector(updateLabel), + userInfo: nil, + repeats: true) + + // register to NSrunloop + RunLoop.current.add(timer, forMode: RunLoop.Mode.common) + counting = true + } + + func disposeTimer() { + if timer != nil { + timer.invalidate() + timer = nil + } + } + + func dispose() { + // reset + pausedDate = nil + + // invalidate timer + disposeTimer() + + // stop counting + finished = true + } +} + +public enum CountdownEffect { + case Anvil + case Burn + case Evaporate + case Fall + case None + case Pixelate + case Scale + case Sparkle + + func toLTMorphing() -> LTMorphingEffect? { + switch self { + case .Anvil : return .anvil + case .Burn : return .burn + case .Evaporate : return .evaporate + case .Fall : return .fall + case .None : return nil + case .Pixelate : return .pixelate + case .Scale : return .scale + case .Sparkle : return .sparkle + } + } +} + +public class CountdownAttributedText: NSObject { + internal let text: String + internal let replacement: String + internal let attributes: [NSAttributedString.Key: Any]? + + public init(text: String, replacement: String, attributes: [NSAttributedString.Key: Any]? = nil) { + self.text = text + self.replacement = replacement + self.attributes = attributes + } } diff --git a/CountdownLabel/Info.plist b/Sources/CountdownLabel/Info.plist similarity index 100% rename from CountdownLabel/Info.plist rename to Sources/CountdownLabel/Info.plist diff --git a/CountdownLabel/LTMorphingLabel/Info.plist b/Sources/CountdownLabel/LTMorphingLabel/Info.plist similarity index 100% rename from CountdownLabel/LTMorphingLabel/Info.plist rename to Sources/CountdownLabel/LTMorphingLabel/Info.plist diff --git a/CountdownLabel/LTMorphingLabel/LTCharacterDiffResult.swift b/Sources/CountdownLabel/LTMorphingLabel/LTCharacterDiffResult.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTCharacterDiffResult.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTCharacterDiffResult.swift diff --git a/CountdownLabel/LTMorphingLabel/LTCharacterLimbo.swift b/Sources/CountdownLabel/LTMorphingLabel/LTCharacterLimbo.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTCharacterLimbo.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTCharacterLimbo.swift diff --git a/CountdownLabel/LTMorphingLabel/LTEasing.swift b/Sources/CountdownLabel/LTMorphingLabel/LTEasing.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTEasing.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTEasing.swift diff --git a/CountdownLabel/LTMorphingLabel/LTEmitterView.swift b/Sources/CountdownLabel/LTMorphingLabel/LTEmitterView.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTEmitterView.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTEmitterView.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingEffect.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingEffect.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingEffect.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingEffect.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Anvil.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Anvil.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel+Anvil.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Anvil.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Burn.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Burn.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel+Burn.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Burn.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Evaporate.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Evaporate.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel+Evaporate.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Evaporate.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Fall.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Fall.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel+Fall.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Fall.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Pixelate.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Pixelate.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel+Pixelate.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Pixelate.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Sparkle.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Sparkle.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel+Sparkle.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel+Sparkle.swift diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel.h b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel.h similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel.h rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel.h diff --git a/CountdownLabel/LTMorphingLabel/LTMorphingLabel.swift b/Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTMorphingLabel.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTMorphingLabel.swift diff --git a/CountdownLabel/LTMorphingLabel/LTStringDiffResult.swift b/Sources/CountdownLabel/LTMorphingLabel/LTStringDiffResult.swift similarity index 100% rename from CountdownLabel/LTMorphingLabel/LTStringDiffResult.swift rename to Sources/CountdownLabel/LTMorphingLabel/LTStringDiffResult.swift diff --git a/CountdownLabel/LTMorphingLabel/Particles/Fire.png b/Sources/CountdownLabel/LTMorphingLabel/Particles/Fire.png similarity index 100% rename from CountdownLabel/LTMorphingLabel/Particles/Fire.png rename to Sources/CountdownLabel/LTMorphingLabel/Particles/Fire.png diff --git a/CountdownLabel/LTMorphingLabel/Particles/Fragment.png b/Sources/CountdownLabel/LTMorphingLabel/Particles/Fragment.png similarity index 100% rename from CountdownLabel/LTMorphingLabel/Particles/Fragment.png rename to Sources/CountdownLabel/LTMorphingLabel/Particles/Fragment.png diff --git a/CountdownLabel/LTMorphingLabel/Particles/Smoke.png b/Sources/CountdownLabel/LTMorphingLabel/Particles/Smoke.png similarity index 100% rename from CountdownLabel/LTMorphingLabel/Particles/Smoke.png rename to Sources/CountdownLabel/LTMorphingLabel/Particles/Smoke.png diff --git a/CountdownLabel/LTMorphingLabel/Particles/Sparkle.png b/Sources/CountdownLabel/LTMorphingLabel/Particles/Sparkle.png similarity index 100% rename from CountdownLabel/LTMorphingLabel/Particles/Sparkle.png rename to Sources/CountdownLabel/LTMorphingLabel/Particles/Sparkle.png diff --git a/CountdownLabel/LTMorphingLabel/tvOS-Info.plist b/Sources/CountdownLabel/LTMorphingLabel/tvOS-Info.plist similarity index 100% rename from CountdownLabel/LTMorphingLabel/tvOS-Info.plist rename to Sources/CountdownLabel/LTMorphingLabel/tvOS-Info.plist From 8b2b254ec9558bf8c75d7777497ce6d105b6d0da Mon Sep 17 00:00:00 2001 From: david Date: Wed, 14 Apr 2021 12:22:36 +0900 Subject: [PATCH 3/5] podspec added --- CountdownLabel.podspec | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CountdownLabel.podspec diff --git a/CountdownLabel.podspec b/CountdownLabel.podspec new file mode 100644 index 0000000..399cd28 --- /dev/null +++ b/CountdownLabel.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = "CountdownLabel" + s.version = '5.0.0' + s.summary = 'Simple countdown UILabel with morphing animation, and some useful function.' + s.homepage = "https://github.com/suzuki-0000/CountdownLabel" + s.license = { :type => "MIT", :file => "LICENSE" } + s.author = { "suzuki_keishi" => "keishi.1983@gmail.com" } + s.source = { :git => "https://github.com/suzuki-0000/CountdownLabel.git", :tag => s.version } + s.platform = :ios, "8.2" + s.source_files = 'CountdownLabel/source/*.swift' + s.source_files = 'CountdownLabel/source/**/*.swift' + s.requires_arc = true + s.frameworks = "UIKit" +end From 5083a7b86855096cf844e403506aac0d1fee90b4 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 14 Apr 2021 12:29:56 +0900 Subject: [PATCH 4/5] README.md update --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ef9680f..7abfef6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ CountdownLabel ======================== -![Swift](http://img.shields.io/badge/swift-4.0-brightgreen.svg) +![Swift](http://img.shields.io/badge/swift-5.0-brightgreen.svg) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/CountdownLabel.svg?style=flat)](http://cocoadocs.org/docsets/CountdownLabel) @@ -23,6 +23,7 @@ Below is a table that shows which version of what you should use for your Swift | Swift version | version | | ------------- | --------------- | +| 5.0 | >= 5.0 | | 4.2 | >= 4.0 | | 4.0, 4.1 | >= 3.0 | | 3.X | >= 2.0 | From 6f9d54112f90132900d54f6d7838e2d99842b3a0 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 21 Apr 2021 15:30:53 +0900 Subject: [PATCH 5/5] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ff6620..d7931c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7.2 +osx_image: xcode12.4 branches: only: - master @@ -9,7 +9,7 @@ env: - LANG=en_US.UTF-8 - FRAMEWORK_NAME="CountdownLabel" matrix: - - DESTINATION="OS=9.2,name=iPhone 6" SCHEME="CountdownLabelTests" SDK="iphonesimulator9.2" $ACTION="test" + - DESTINATION="OS=11.0,name=iPhone 11" SCHEME="CountdownLabelTests" SDK="iphonesimulator11.0" $ACTION="test" before_install: - brew update