From e185e373fc1da99bdf8403a5a9258c093eb88703 Mon Sep 17 00:00:00 2001 From: onevcat Date: Sat, 26 Jan 2019 01:12:58 +0900 Subject: [PATCH] Default build with Swift 5 --- Demo/Kingfisher-Demo.xcodeproj/project.pbxproj | 14 ++------------ Kingfisher.xcodeproj/project.pbxproj | 14 ++++++++++---- Sources/Extensions/NSButton+Kingfisher.swift | 4 ++-- .../Extensions/WKInterfaceImage+Kingfisher.swift | 2 +- Sources/Image/Image.swift | 2 +- Tests/KingfisherTests/ImageCacheTests.swift | 4 ++-- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj b/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj index 5f6fcd644..842622ac5 100644 --- a/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj +++ b/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj @@ -700,7 +700,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; }; name = Debug; }; @@ -721,7 +720,6 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; }; name = Release; }; @@ -741,7 +739,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -763,7 +760,6 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; TARGETED_DEVICE_FAMILY = 3; }; name = Release; @@ -782,7 +778,6 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; TARGETED_DEVICE_FAMILY = 4; }; name = Debug; @@ -801,7 +796,6 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; TARGETED_DEVICE_FAMILY = 4; }; name = Release; @@ -824,7 +818,6 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = On; TARGETED_DEVICE_FAMILY = 4; }; name = Debug; @@ -847,7 +840,6 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = On; TARGETED_DEVICE_FAMILY = 4; }; name = Release; @@ -904,7 +896,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 10.0; WATCHOS_DEPLOYMENT_TARGET = 3.0; @@ -955,7 +947,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 10.0; VALIDATE_PRODUCT = YES; @@ -973,7 +965,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; }; name = Debug; }; @@ -988,7 +979,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; }; name = Release; }; diff --git a/Kingfisher.xcodeproj/project.pbxproj b/Kingfisher.xcodeproj/project.pbxproj index ea0ed1bbf..1f950db44 100644 --- a/Kingfisher.xcodeproj/project.pbxproj +++ b/Kingfisher.xcodeproj/project.pbxproj @@ -859,11 +859,11 @@ }; D1ED2D341AD2D09F00CFC3EB = { CreatedOnToolsVersion = 6.2; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; }; D1ED2D3E1AD2D09F00CFC3EB = { CreatedOnToolsVersion = 6.2; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; }; }; }; @@ -1413,6 +1413,8 @@ SDKROOT = appletvos; SWIFT_OBJC_BRIDGING_HEADER = "Tests/KingfisherTests/KingfisherTests-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = ""; + TARGETED_DEVICE_FAMILY = 3; }; name = Debug; }; @@ -1431,6 +1433,8 @@ SWIFT_OBJC_BRIDGING_HEADER = "Tests/KingfisherTests/KingfisherTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = ""; + TARGETED_DEVICE_FAMILY = 3; }; name = Release; }; @@ -1638,7 +1642,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 10.0; WATCHOS_DEPLOYMENT_TARGET = 3.0; @@ -1689,7 +1693,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 10.0; VALIDATE_PRODUCT = YES; @@ -1763,6 +1767,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/KingfisherTests/KingfisherTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1778,6 +1783,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/KingfisherTests/KingfisherTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Sources/Extensions/NSButton+Kingfisher.swift b/Sources/Extensions/NSButton+Kingfisher.swift index 4ca6494ae..3ae4e947f 100644 --- a/Sources/Extensions/NSButton+Kingfisher.swift +++ b/Sources/Extensions/NSButton+Kingfisher.swift @@ -297,7 +297,7 @@ extension KingfisherWrapper where Base: NSButton { extension KingfisherWrapper where Base: NSButton { /// Gets the image URL bound to this button. - @available(*, obsoleted: 5.0, message: "Use `taskIdentifier` instead to identify a setting task.") + @available(*, deprecated, message: "Use `taskIdentifier` instead to identify a setting task.") public private(set) var webURL: URL? { get { return nil } set { } @@ -305,7 +305,7 @@ extension KingfisherWrapper where Base: NSButton { /// Gets the image URL bound to this button. - @available(*, obsoleted: 5.0, message: "Use `alternateTaskIdentifier` instead to identify a setting task.") + @available(*, deprecated, message: "Use `alternateTaskIdentifier` instead to identify a setting task.") public private(set) var alternateWebURL: URL? { get { return nil } set { } diff --git a/Sources/Extensions/WKInterfaceImage+Kingfisher.swift b/Sources/Extensions/WKInterfaceImage+Kingfisher.swift index aa59efcdb..55b44dccd 100644 --- a/Sources/Extensions/WKInterfaceImage+Kingfisher.swift +++ b/Sources/Extensions/WKInterfaceImage+Kingfisher.swift @@ -172,7 +172,7 @@ extension KingfisherWrapper where Base: WKInterfaceImage { extension KingfisherWrapper where Base: WKInterfaceImage { /// Gets the image URL bound to this image view. - @available(*, obsoleted: 5.0, message: "Use `taskIdentifier` instead to identify a setting task.") + @available(*, deprecated, message: "Use `taskIdentifier` instead to identify a setting task.") public private(set) var webURL: URL? { get { return nil } set { } diff --git a/Sources/Image/Image.swift b/Sources/Image/Image.swift index f538d47d2..b99ebe74d 100644 --- a/Sources/Image/Image.swift +++ b/Sources/Image/Image.swift @@ -205,7 +205,7 @@ extension KingfisherWrapper where Base: Image { guard let animatedImage = GIFAnimatedImage(from: imageSource, for: info, options: options) else { return nil } - let image: Image? + var image: Image? if options.onlyFirstFrame { image = animatedImage.images.first } else { diff --git a/Tests/KingfisherTests/ImageCacheTests.swift b/Tests/KingfisherTests/ImageCacheTests.swift index 487cf0590..11c36c668 100644 --- a/Tests/KingfisherTests/ImageCacheTests.swift +++ b/Tests/KingfisherTests/ImageCacheTests.swift @@ -279,8 +279,8 @@ class ImageCacheTests: XCTestCase { XCTAssertEqual(hashes.count, 1) XCTAssertEqual(hashes.first!, self.cache.hash(forKey: key)) - - NotificationCenter.default.removeObserver(self.observer) + guard let o = self.observer else { return } + NotificationCenter.default.removeObserver(o) exp.fulfill() }