From 28df34d30024b7601bf46761e1197bdd7777348c Mon Sep 17 00:00:00 2001 From: Quentin Jin Date: Mon, 18 Mar 2019 21:07:08 +0800 Subject: [PATCH] Update to Swift 5.0 --- Schedule.xcodeproj/project.pbxproj | 34 ++++++++++++++++++++++++------ Sources/Schedule/Interval.swift | 5 ----- Sources/Schedule/Task.swift | 6 +++--- Sources/Schedule/TaskCenter.swift | 8 +++++-- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Schedule.xcodeproj/project.pbxproj b/Schedule.xcodeproj/project.pbxproj index d25aff4..e61b5cd 100644 --- a/Schedule.xcodeproj/project.pbxproj +++ b/Schedule.xcodeproj/project.pbxproj @@ -109,7 +109,7 @@ OBJ_9 /* Atomic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Atomic.swift; sourceTree = ""; }; "Schedule::Schedule::Product" /* Schedule.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Schedule.framework; sourceTree = BUILT_PRODUCTS_DIR; }; "Schedule::ScheduleDemo::Product" /* ScheduleDemo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = ScheduleDemo; sourceTree = BUILT_PRODUCTS_DIR; }; - "Schedule::ScheduleTests::Product" /* ScheduleTests.xctest */ = {isa = PBXFileReference; lastKnownFileType = file; path = ScheduleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + "Schedule::ScheduleTests::Product" /* ScheduleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = ScheduleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -318,12 +318,24 @@ isa = PBXProject; attributes = { LastUpgradeCheck = 9999; + TargetAttributes = { + "Schedule::Schedule" = { + LastSwiftMigration = 1020; + }; + "Schedule::ScheduleDemo" = { + LastSwiftMigration = 1020; + }; + "Schedule::ScheduleTests" = { + LastSwiftMigration = 1020; + }; + }; }; buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "Schedule" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = OBJ_5; @@ -485,7 +497,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGET_NAME = Schedule; TVOS_DEPLOYMENT_TARGET = 10.0; WATCHOS_DEPLOYMENT_TARGET = 3.0; @@ -513,7 +525,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGET_NAME = Schedule; TVOS_DEPLOYMENT_TARGET = 10.0; WATCHOS_DEPLOYMENT_TARGET = 3.0; @@ -537,7 +549,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES; SWIFT_FORCE_STATIC_LINK_STDLIB = NO; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGET_NAME = ScheduleDemo; }; name = Debug; @@ -559,7 +571,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES; SWIFT_FORCE_STATIC_LINK_STDLIB = NO; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGET_NAME = ScheduleDemo; }; name = Release; @@ -605,13 +617,17 @@ ); HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Schedule.xcodeproj/ScheduleTests_Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGET_NAME = ScheduleTests; + TVOS_DEPLOYMENT_TARGET = 10.0; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Debug; }; @@ -626,13 +642,17 @@ ); HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Schedule.xcodeproj/ScheduleTests_Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGET_NAME = ScheduleTests; + TVOS_DEPLOYMENT_TARGET = 10.0; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Release; }; diff --git a/Sources/Schedule/Interval.swift b/Sources/Schedule/Interval.swift index 3ab230c..fcb3085 100644 --- a/Sources/Schedule/Interval.swift +++ b/Sources/Schedule/Interval.swift @@ -48,11 +48,6 @@ extension Interval { extension Interval: Hashable { - /// The hashValue of this interval. - public var hashValue: Int { - return nanoseconds.hashValue - } - /// Returns a boolean value indicating whether two intervals are equal. public static func == (lhs: Interval, rhs: Interval) -> Bool { return lhs.nanoseconds == rhs.nanoseconds diff --git a/Sources/Schedule/Task.swift b/Sources/Schedule/Task.swift index 85a546b..12abcde 100644 --- a/Sources/Schedule/Task.swift +++ b/Sources/Schedule/Task.swift @@ -306,9 +306,9 @@ open class Task { extension Task: Hashable { - /// The task's hash value. - public var hashValue: Int { - return ObjectIdentifier(self).hashValue + + public func hash(into hasher: inout Hasher) { + hasher.combine(ObjectIdentifier(self)) } /// Returns a boolean value indicating whether two tasks are equal. diff --git a/Sources/Schedule/TaskCenter.swift b/Sources/Schedule/TaskCenter.swift index e164112..c546bb1 100644 --- a/Sources/Schedule/TaskCenter.swift +++ b/Sources/Schedule/TaskCenter.swift @@ -9,11 +9,15 @@ extension TaskCenter { weak var task: Task? // To find slot - let hashValue: Int + let hash: Int init(_ task: Task) { self.task = task - self.hashValue = task.hashValue + self.hash = task.hashValue + } + + func hash(into hasher: inout Hasher) { + hasher.combine(hash) } // To find task