diff --git a/Cache.podspec b/Cache.podspec index b8c6c901..ff1799e2 100644 --- a/Cache.podspec +++ b/Cache.podspec @@ -19,5 +19,5 @@ Pod::Spec.new do |s| s.frameworks = 'Foundation' - s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' } + s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' } end diff --git a/Cache.xcodeproj/project.pbxproj b/Cache.xcodeproj/project.pbxproj index 0f1b87c5..0d95939b 100644 --- a/Cache.xcodeproj/project.pbxproj +++ b/Cache.xcodeproj/project.pbxproj @@ -667,7 +667,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1130; ORGANIZATIONNAME = "Hyper Interaktiv AS"; TargetAttributes = { BDEDD3551DBCE5B1007416A6 = { @@ -700,6 +700,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = D5DC59D61C20593E003BD79B; @@ -999,6 +1000,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.2; }; @@ -1024,6 +1026,7 @@ PRODUCT_NAME = Cache; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.2; }; @@ -1045,6 +1048,7 @@ SDKROOT = appletvos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 10.0; }; name = Debug; @@ -1063,6 +1067,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-tvOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 10.0; }; name = Release; @@ -1077,6 +1082,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1089,6 +1095,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1111,6 +1118,7 @@ PRODUCT_NAME = Cache; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1133,6 +1141,7 @@ PRODUCT_NAME = Cache; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1148,6 +1157,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1163,6 +1173,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1170,6 +1181,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1229,6 +1241,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1294,6 +1307,7 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache; PRODUCT_NAME = Cache; SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1313,6 +1327,7 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache; PRODUCT_NAME = Cache; SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme b/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme index d05b90d7..8cfd922a 100644 --- a/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme +++ b/Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme @@ -1,6 +1,6 @@ + + + + - - - - - - - - + + + + - - - - - - - - + + + + - - - - - - - - (_ data: Data, to type: T.Type) throws -> T { return try JSONDecoder().decode(T.self, from: data) } + } diff --git a/Source/Shared/Library/ImageWrapper.swift b/Source/Shared/Library/ImageWrapper.swift index 65875f91..53ae2f91 100644 --- a/Source/Shared/Library/ImageWrapper.swift +++ b/Source/Shared/Library/ImageWrapper.swift @@ -1,6 +1,7 @@ import Foundation public struct ImageWrapper: Codable { + public let image: Image public enum CodingKeys: String, CodingKey { @@ -29,4 +30,5 @@ public struct ImageWrapper: Codable { try container.encode(data, forKey: CodingKeys.image) } + } diff --git a/Source/Shared/Library/TransformerFactory.swift b/Source/Shared/Library/TransformerFactory.swift index d6b7b67e..74a2e916 100644 --- a/Source/Shared/Library/TransformerFactory.swift +++ b/Source/Shared/Library/TransformerFactory.swift @@ -1,6 +1,7 @@ import Foundation public class TransformerFactory { + public static func forData() -> Transformer { let toData: (Data) throws -> Data = { $0 } @@ -35,4 +36,5 @@ public class TransformerFactory { return Transformer(toData: toData, fromData: fromData) } + } diff --git a/Source/iOS/UIImage+Extensions.swift b/Source/iOS/UIImage+Extensions.swift index 611990e1..05678cf6 100644 --- a/Source/iOS/UIImage+Extensions.swift +++ b/Source/iOS/UIImage+Extensions.swift @@ -1,3 +1,4 @@ +#if canImport(UIKit) import UIKit /// Helper UIImage extension. @@ -22,14 +23,10 @@ extension UIImage { /// Convert to data func cache_toData() -> Data? { - #if swift(>=4.2) return hasAlpha ? pngData() : jpegData(compressionQuality: 1.0) - #else - return hasAlpha - ? UIImagePNGRepresentation(self) - : UIImageJPEGRepresentation(self, 1.0) - #endif } } + +#endif diff --git a/Tests/Mac/Helpers/NSImage+ExtensionsTests.swift b/Tests/Mac/Helpers/NSImage+ExtensionsTests.swift index b0cbc017..d42e0d85 100644 --- a/Tests/Mac/Helpers/NSImage+ExtensionsTests.swift +++ b/Tests/Mac/Helpers/NSImage+ExtensionsTests.swift @@ -1,3 +1,6 @@ + +#if canImport(Cocoa) + import Cocoa @testable import Cache @@ -14,3 +17,5 @@ extension NSImage { .representation(using: imageFileType, properties: [:])! } } + +#endif diff --git a/Tests/Mac/Helpers/TestHelper+OSX.swift b/Tests/Mac/Helpers/TestHelper+OSX.swift index 35e35f68..ff6f1467 100644 --- a/Tests/Mac/Helpers/TestHelper+OSX.swift +++ b/Tests/Mac/Helpers/TestHelper+OSX.swift @@ -1,3 +1,5 @@ +#if canImport(Cocoa) + import Cocoa extension TestHelper { @@ -9,3 +11,5 @@ extension TestHelper { return image } } + +#endif diff --git a/Tests/Shared/TestHelper.swift b/Tests/Shared/TestHelper.swift index 8f01c0e9..c7ff30a9 100644 --- a/Tests/Shared/TestHelper.swift +++ b/Tests/Shared/TestHelper.swift @@ -1,27 +1,17 @@ -import Foundation -#if os(iOS) || os(tvOS) + import UIKit -#elseif os(OSX) -import AppKit -#endif +import Foundation + struct TestHelper { static func data(_ length : Int) -> Data { let buffer = [UInt8](repeating: 0, count: length) - return Data(bytes: buffer) + return Data(buffer) } static func triggerApplicationEvents() { - #if (iOS) NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil) NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil) - #elseif os(tvOS) - NotificationCenter.default.post(name: Notification.Name.UIApplicationDidEnterBackground, object: nil) - NotificationCenter.default.post(name: Notification.Name.UIApplicationWillTerminate, object: nil) - #else - NotificationCenter.default.post(name: NSApplication.willTerminateNotification, object: nil) - NotificationCenter.default.post(name: NSApplication.didResignActiveNotification, object: nil) - #endif } }