From 90b2e1185a99e8ba8a3360c7d0eb6845fb1fbf2c Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Thu, 31 Oct 2024 14:56:59 +0000 Subject: [PATCH 1/5] Compile UI code in SwiftPM package, but add conditional compilation checks --- Package.swift | 1 - Updates/Classes/Core/Updates.swift | 12 ++++++++++++ Updates/Classes/UI/Updates+UIDevice.swift | 17 ----------------- Updates/Classes/UI/UpdatesUI.swift | 3 +++ 4 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 Updates/Classes/UI/Updates+UIDevice.swift diff --git a/Package.swift b/Package.swift index 61986fb..2f1c9c2 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,6 @@ let package = Package( name: "Updates", dependencies: [], path: "Updates/Classes", - exclude: ["UI"], resources: [.copy("../../Example/Pods/Target Support Files/Updates/PrivacyInfo.xcprivacy")] ) ] diff --git a/Updates/Classes/Core/Updates.swift b/Updates/Classes/Core/Updates.swift index 114a608..1579fe9 100644 --- a/Updates/Classes/Core/Updates.swift +++ b/Updates/Classes/Core/Updates.swift @@ -192,3 +192,15 @@ public class Updates { } } + +#if canImport(UIKit) +import UIKit + +public extension Updates { + + static func checkForUpdates(completion: @escaping (UpdatesResult) -> Void) { + Updates.checkForUpdates(currentOSVersion: UIDevice.current.systemVersion, completion: completion) + } + +} +#endif diff --git a/Updates/Classes/UI/Updates+UIDevice.swift b/Updates/Classes/UI/Updates+UIDevice.swift deleted file mode 100644 index 28466c2..0000000 --- a/Updates/Classes/UI/Updates+UIDevice.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// Updates+UIDevice.swift -// Updates -// -// Created by Ross Butler on 8/8/19. -// - -import Foundation -import UIKit - -public extension Updates { - - static func checkForUpdates(completion: @escaping (UpdatesResult) -> Void) { - Updates.checkForUpdates(currentOSVersion: UIDevice.current.systemVersion, completion: completion) - } - -} diff --git a/Updates/Classes/UI/UpdatesUI.swift b/Updates/Classes/UI/UpdatesUI.swift index f3f4ca7..8590003 100644 --- a/Updates/Classes/UI/UpdatesUI.swift +++ b/Updates/Classes/UI/UpdatesUI.swift @@ -5,9 +5,11 @@ // Created by Ross Butler on 12/27/18. // +#if canImport(UIKit) import Foundation import StoreKit import SafariServices +import Updates public class UpdatesUI: NSObject { @@ -248,3 +250,4 @@ private extension UpdatesUI { } } +#endif From 151b11dee65b7522c2f4dc5a9c71886d711bed97 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Thu, 31 Oct 2024 14:57:24 +0000 Subject: [PATCH 2/5] Make an API public that is used in the UI code, so external users can use the same APIs --- Updates/Classes/Core/Updates.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Updates/Classes/Core/Updates.swift b/Updates/Classes/Core/Updates.swift index 1579fe9..ccd5f69 100644 --- a/Updates/Classes/Core/Updates.swift +++ b/Updates/Classes/Core/Updates.swift @@ -49,7 +49,7 @@ public class Updates { /// - appStoreId: The app store identifier specified as a String. /// - Returns: The URL required to launch the App Store page for the specified app, /// provided a valid identifier is provided. - static func appStoreURL(for appStoreId: String) -> URL? { + public static func appStoreURL(for appStoreId: String) -> URL? { Updates.appStoreId = appStoreId return appStoreURL } From 709e3ab56d95133aca299cb6a1f9f25c9aac3eca Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Thu, 31 Oct 2024 14:57:52 +0000 Subject: [PATCH 3/5] Retrieve minimum iOS version when available --- Updates/Classes/Core/Updates.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Updates/Classes/Core/Updates.swift b/Updates/Classes/Core/Updates.swift index ccd5f69..50dd021 100644 --- a/Updates/Classes/Core/Updates.swift +++ b/Updates/Classes/Core/Updates.swift @@ -78,7 +78,7 @@ public class Updates { public static var notifying: NotificationMode = .once - public static var minimumOSVersion: String? + public static var minimumOSVersion: String? = Bundle.main.infoDictionary?["MinimumOSVersion"] as? String public static var minimumOptionalAppVersion: String? From a90a03ee6fc133d36c615b95ec90b50891ae19fe Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Thu, 31 Oct 2024 14:58:12 +0000 Subject: [PATCH 4/5] Configuration should load newVersionString as latestVersion --- Updates/Classes/Core/Updates.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Updates/Classes/Core/Updates.swift b/Updates/Classes/Core/Updates.swift index 50dd021..d49bdfe 100644 --- a/Updates/Classes/Core/Updates.swift +++ b/Updates/Classes/Core/Updates.swift @@ -187,7 +187,7 @@ public class Updates { releaseNotes: releaseNotes, updateType: updateType, updatingMode: updatingMode, - latestVersion: versionString + latestVersion: newVersionString ) } From 10dd492ec5380babdfbc7712d1de7f8c98798a1d Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Thu, 31 Oct 2024 16:30:06 +0000 Subject: [PATCH 5/5] Fix whitespace --- Updates/Classes/Core/Updates.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Updates/Classes/Core/Updates.swift b/Updates/Classes/Core/Updates.swift index d49bdfe..bea6394 100644 --- a/Updates/Classes/Core/Updates.swift +++ b/Updates/Classes/Core/Updates.swift @@ -197,10 +197,8 @@ public class Updates { import UIKit public extension Updates { - static func checkForUpdates(completion: @escaping (UpdatesResult) -> Void) { Updates.checkForUpdates(currentOSVersion: UIDevice.current.systemVersion, completion: completion) } - } #endif