diff --git a/ios/engine/KMEI/KeymanEngine/Classes/Model/Version.swift b/ios/engine/KMEI/KeymanEngine/Classes/Model/Version.swift index b457dbd1bb..e24e4fda06 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/Model/Version.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/Model/Version.swift @@ -40,6 +40,26 @@ public struct Version: Comparable { self.components = components } + public init?(_ components: [Int]) { + if components.count == 0 { + return nil + } + + var string = "" + + for i in components { + guard i >= 0 else { + return nil + } + + let dot = (string == "" ? "" : ".") + string = "\(string)\(dot)\(i)" + } + + self.string = string + self.components = components // Swift arrays are value types, not reference types! + } + public static func <(lhs: Version, rhs: Version) -> Bool { let len = max(lhs.components.count, rhs.components.count) for i in 0..= 2) { + return Version([self.components[0], self.components[1]])! + } else { + // If we somehow have just a major version, append a simple '0'. + return Version([self.components[0], 0])! + } + } } diff --git a/ios/keyman/Keyman/Keyman/InfoViewController/InfoViewController.swift b/ios/keyman/Keyman/Keyman/InfoViewController/InfoViewController.swift index 00b7437ea8..86b30467d9 100644 --- a/ios/keyman/Keyman/Keyman/InfoViewController/InfoViewController.swift +++ b/ios/keyman/Keyman/Keyman/InfoViewController/InfoViewController.swift @@ -61,7 +61,7 @@ class InfoViewController: UIViewController, UIWebViewDelegate { } private func loadFromServer() { - let appVersion = Version.current + let appVersion = Version.current.majorMinor let url = "https://help.keyman.com/products/iphone-and-ipad/\(appVersion.string)/?embed=ios" webView.loadRequest(URLRequest(url: URL(string: url)!)) log.debug("Info page URL: \(url)") diff --git a/ios/keyman/Keyman/Keyman/SetUpViewController/SetUpViewController.swift b/ios/keyman/Keyman/Keyman/SetUpViewController/SetUpViewController.swift index 806d450ac0..0d6c2a82f9 100644 --- a/ios/keyman/Keyman/Keyman/SetUpViewController/SetUpViewController.swift +++ b/ios/keyman/Keyman/Keyman/SetUpViewController/SetUpViewController.swift @@ -68,7 +68,7 @@ class SetUpViewController: UIViewController, UIWebViewDelegate { } private func loadFromServer() { - let appVersion = Version.current + let appVersion = Version.current.majorMinor let url = "https://help.keyman.com/products/iphone-and-ipad/\(appVersion.string)" + "/installing-system-keyboard.php?embed=ios" webView.loadRequest(URLRequest(url: URL(string: url)!))