diff --git a/Package.swift b/Package.swift index 560f290..a59ac8e 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( name: "WordPressUI", - platforms: [.iOS(.v11)], + platforms: [.iOS(.v13)], products: [ .library(name: "WordPressUI", targets: ["WordPressUI"]), .library(name: "WordPressUIObjC", targets: ["WordPressUIObjC"]) diff --git a/Sources/WordPressUI/Extensions/Gravatar/Gravatar.swift b/Sources/WordPressUI/Extensions/Gravatar/Gravatar.swift index c266524..85f3b56 100644 --- a/Sources/WordPressUI/Extensions/Gravatar/Gravatar.swift +++ b/Sources/WordPressUI/Extensions/Gravatar/Gravatar.swift @@ -1,4 +1,5 @@ import Foundation +import CryptoKit /// Helper Enum that specifies all of the available Gravatar Image Ratings /// TODO: Convert into a pure Swift String Enum. It's done this way to maintain ObjC Compatibility @@ -106,7 +107,7 @@ public struct Gravatar { return email .lowercased() .trimmingCharacters(in: .whitespaces) - .sha256Hash() + .sha256() } } @@ -146,3 +147,17 @@ public extension Gravatar { self.canonicalURL = sanitizedURL } } + +extension String { + func sha256() -> String { + guard let input = self.data(using: .utf8) else { + return "" // The conversion to .utf8 should never fail + } + let digest = SHA256.hash(data: input) + var output = "" + for byte in digest { + output.append(String(format: "%02x", byte)) + } + return output + } +} diff --git a/Sources/WordPressUI/Extensions/UIImageView+Gravatar.swift b/Sources/WordPressUI/Extensions/UIImageView+Gravatar.swift index 8fc7beb..b8afb68 100644 --- a/Sources/WordPressUI/Extensions/UIImageView+Gravatar.swift +++ b/Sources/WordPressUI/Extensions/UIImageView+Gravatar.swift @@ -1,10 +1,6 @@ import Foundation import UIKit -#if SWIFT_PACKAGE -import WordPressUIObjC -#endif - /// Wrapper class used to ensure removeObserver is called private class GravatarNotificationWrapper { let observer: NSObjectProtocol diff --git a/Sources/WordPressUI/Extensions/UIImageView+Networking.swift b/Sources/WordPressUI/Extensions/UIImageView+Networking.swift index 010c4d6..c04955e 100644 --- a/Sources/WordPressUI/Extensions/UIImageView+Networking.swift +++ b/Sources/WordPressUI/Extensions/UIImageView+Networking.swift @@ -1,10 +1,6 @@ import Foundation import UIKit -#if SWIFT_PACKAGE -import WordPressUIObjC -#endif - public extension UIImageView { enum ImageDownloadError: Error { case noURLSpecifiedInRequest