From 7acfbaa44a918e5dcacb67c94e62dd4ae0bb888e Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 3 Apr 2019 08:43:04 +0800 Subject: [PATCH] convert to Swift 5 --- .swift-version | 2 +- China.xcodeproj/project.pbxproj | 17 +++++++---------- README.md | 4 +++- Sources/MonkeyKing.swift | 8 ++------ 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.swift-version b/.swift-version index bf77d54..819e07a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2 +5.0 diff --git a/China.xcodeproj/project.pbxproj b/China.xcodeproj/project.pbxproj index bcbe432..8582626 100644 --- a/China.xcodeproj/project.pbxproj +++ b/China.xcodeproj/project.pbxproj @@ -252,12 +252,12 @@ TargetAttributes = { 50FBA6B41BA2AFAD00E69BB3 = { CreatedOnToolsVersion = 7.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 50FBA6CE1BA2BBE900E69BB3 = { CreatedOnToolsVersion = 7.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; }; }; }; @@ -266,6 +266,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -490,8 +491,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nixWork.China; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -508,8 +508,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nixWork.China; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -531,8 +530,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -555,8 +553,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nixWork.MonkeyKing; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/README.md b/README.md index 397d11b..9400f0c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,9 @@ MonkeyKing also supports **OAuth** and **Mobile payment** via WeChat and Alipay! ## Requirements -Swift 4.2, iOS 8 +Swift 5, iOS 8 + +(For Swift 4.2, use version 1.13.0) (For Swift 4.1/4.0, use version 1.11.0) diff --git a/Sources/MonkeyKing.swift b/Sources/MonkeyKing.swift index 859bbf2..8c3e6b2 100644 --- a/Sources/MonkeyKing.swift +++ b/Sources/MonkeyKing.swift @@ -81,10 +81,6 @@ public class MonkeyKing: NSObject { } } - public var hashValue: Int { - return appID.hashValue - } - public func hash(into hasher: inout Hasher) { hasher.combine(appID) } @@ -212,7 +208,7 @@ extension MonkeyKing { guard let account = shared.accountSet[.weChat], - let info = dict?[account.appID] as? [String: Any], + let info = dict[account.appID] as? [String: Any], let result = info["result"] as? String, let resultCode = Int(result) else { return false @@ -399,7 +395,7 @@ extension MonkeyKing { guard let data = UIPasteboard.general.data(forPasteboardType: "com.alipay.openapi.pb.resp.\(appID)"), let dict = try? PropertyListSerialization.propertyList(from: data, options: PropertyListSerialization.MutabilityOptions(), format: nil) as? [String: Any], - let objects = dict?["$objects"] as? NSArray, + let objects = dict["$objects"] as? NSArray, let result = objects[12] as? Int else { return false }