]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
App: bump minimum OS versions
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 14 Feb 2023 14:31:52 +0000 (15:31 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 15 Feb 2023 13:20:30 +0000 (14:20 +0100)
This allows us to remove a good deal of legacy cruft.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
13 files changed:
Package.swift
Sources/Shared/Model/NETunnelProviderProtocol+Extension.swift
Sources/WireGuardApp/UI/iOS/View/KeyValueCell.swift
Sources/WireGuardApp/UI/iOS/View/SwitchCell.swift
Sources/WireGuardApp/UI/iOS/View/TextCell.swift
Sources/WireGuardApp/UI/iOS/View/TunnelEditKeyValueCell.swift
Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift
Sources/WireGuardApp/UI/iOS/ViewController/LogViewController.swift
Sources/WireGuardApp/UI/iOS/ViewController/MainViewController.swift
Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift
Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
Sources/WireGuardApp/UI/macOS/LoginItemHelper/main.m
WireGuard.xcodeproj/project.pbxproj

index 8e3864fd02e141568266a5fdcabf19df40cfe650..5d15a1b0dd840942a03219034e17c8b5a3d2db38 100644 (file)
@@ -6,8 +6,8 @@ import PackageDescription
 let package = Package(
     name: "WireGuardKit",
     platforms: [
-        .macOS(.v10_14),
-        .iOS(.v12)
+        .macOS(.v12),
+        .iOS(.v15)
     ],
     products: [
         .library(name: "WireGuardKit", targets: ["WireGuardKit"])
index ecb6e1f2b953d0ec1cb2097851fc182b1dc6085b..b6772f87a5b194d4e4e5b64ab0287366b999ba42 100644 (file)
@@ -82,24 +82,22 @@ extension NETunnelProviderProtocol {
             return true
         }
         #elseif os(iOS)
-        if #available(iOS 15, *) {
-            /* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one.
-             * The iOS 14 ones are 96 bits, while the iOS 15 ones are 160 bits. We do this so
-             * that we can have fast set exclusion in deleteReferences safely. */
-            if passwordReference != nil && passwordReference!.count == 12 {
-                var result: CFTypeRef?
-                let ret = SecItemCopyMatching([kSecValuePersistentRef: passwordReference!,
-                                               kSecReturnPersistentRef: true] as CFDictionary,
-                                               &result)
-                if ret != errSecSuccess || result == nil {
-                    return false
-                }
-                guard let newReference = result as? Data else { return false }
-                if !newReference.elementsEqual(passwordReference!) {
-                    wg_log(.info, message: "Migrating iOS 14-style keychain reference to iOS 15-style keychain reference for '\(name)'")
-                    passwordReference = newReference
-                    return true
-                }
+        /* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one.
+         * The iOS 14 ones are 96 bits, while the iOS 15 ones are 160 bits. We do this so
+         * that we can have fast set exclusion in deleteReferences safely. */
+        if passwordReference != nil && passwordReference!.count == 12 {
+            var result: CFTypeRef?
+            let ret = SecItemCopyMatching([kSecValuePersistentRef: passwordReference!,
+                                           kSecReturnPersistentRef: true] as CFDictionary,
+                                           &result)
+            if ret != errSecSuccess || result == nil {
+                return false
+            }
+            guard let newReference = result as? Data else { return false }
+            if !newReference.elementsEqual(passwordReference!) {
+                wg_log(.info, message: "Migrating iOS 14-style keychain reference to iOS 15-style keychain reference for '\(name)'")
+                passwordReference = newReference
+                return true
             }
         }
         #endif
index e8c38503abe6a03d7e3cf48f4223a84678479896..3162abf34a0d49f7540578d2a4354145b0d1c144 100644 (file)
@@ -9,11 +9,7 @@ class KeyValueCell: UITableViewCell {
         let keyLabel = UILabel()
         keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
         keyLabel.adjustsFontForContentSizeCategory = true
-        if #available(iOS 13.0, *) {
-            keyLabel.textColor = .label
-        } else {
-            keyLabel.textColor = .black
-        }
+        keyLabel.textColor = .label
         keyLabel.textAlignment = .left
         return keyLabel
     }()
@@ -35,11 +31,7 @@ class KeyValueCell: UITableViewCell {
         valueTextField.autocapitalizationType = .none
         valueTextField.autocorrectionType = .no
         valueTextField.spellCheckingType = .no
-        if #available(iOS 13.0, *) {
-            valueTextField.textColor = .secondaryLabel
-        } else {
-            valueTextField.textColor = .gray
-        }
+        valueTextField.textColor = .secondaryLabel
         return valueTextField
     }()
 
@@ -64,18 +56,10 @@ class KeyValueCell: UITableViewCell {
 
     var isValueValid = true {
         didSet {
-            if #available(iOS 13.0, *) {
-                if isValueValid {
-                    keyLabel.textColor = .label
-                } else {
-                    keyLabel.textColor = .systemRed
-                }
+            if isValueValid {
+                keyLabel.textColor = .label
             } else {
-                if isValueValid {
-                    keyLabel.textColor = .black
-                } else {
-                    keyLabel.textColor = .red
-                }
+                keyLabel.textColor = .systemRed
             }
         }
     }
index 3952ffdcee828ba2de393dfb9b3df7aa471fdd5e..82d3dec43c99b3fa85fa0b4b9ac797db28c28047 100644 (file)
@@ -16,11 +16,7 @@ class SwitchCell: UITableViewCell {
         get { return switchView.isEnabled }
         set(value) {
             switchView.isEnabled = value
-            if #available(iOS 13.0, *) {
-                textLabel?.textColor = value ? .label : .secondaryLabel
-            } else {
-                textLabel?.textColor = value ? .black : .gray
-            }
+            textLabel?.textColor = value ? .label : .secondaryLabel
         }
     }
 
index 9de50127e309e899e97aa984edaf0faf4826ef7a..5c39512b2c0e9143d74a88f6fdb472fe7461a4a0 100644 (file)
@@ -28,11 +28,7 @@ class TextCell: UITableViewCell {
     override func prepareForReuse() {
         super.prepareForReuse()
         message = ""
-        if #available(iOS 13.0, *) {
-            setTextColor(.label)
-        } else {
-            setTextColor(.black)
-        }
+        setTextColor(.label)
         setTextAlignment(.left)
     }
 }
index ac6f063d51a8c9b8b5ea4291e5b8ae8af61c752c..a44af7cbc569f45875ad2f39482ca2b373a20d2c 100644 (file)
@@ -30,11 +30,7 @@ class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
 
         copyableGesture = false
-        if #available(iOS 13.0, *) {
-            valueTextField.textColor = .label
-        } else {
-            valueTextField.textColor = .black
-        }
+        valueTextField.textColor = .label
         valueTextField.isEnabled = true
         valueLabelScrollView.isScrollEnabled = false
         valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true
index 4dbe97cfa2fc906bac4843aa86e948bef0ea1b88..97948b86b865754a78b9d49870bb87d94a5139fd 100644 (file)
@@ -41,21 +41,13 @@ class TunnelListCell: UITableViewCell {
         label.font = UIFont.preferredFont(forTextStyle: .caption2)
         label.adjustsFontForContentSizeCategory = true
         label.numberOfLines = 1
-        if #available(iOS 13.0, *) {
-            label.textColor = .secondaryLabel
-        } else {
-            label.textColor = .gray
-        }
+        label.textColor = .secondaryLabel
         return label
     }()
 
     let busyIndicator: UIActivityIndicatorView = {
         let busyIndicator: UIActivityIndicatorView
-        if #available(iOS 13.0, *) {
-            busyIndicator = UIActivityIndicatorView(style: .medium)
-        } else {
-            busyIndicator = UIActivityIndicatorView(style: .gray)
-        }
+        busyIndicator = UIActivityIndicatorView(style: .medium)
         busyIndicator.hidesWhenStopped = true
         return busyIndicator
     }()
index eed5e46be7959f02f46c43d6000c49c1319b1495..4e4a13157df7bea3eb510168c75028550ff8683b 100644 (file)
@@ -15,15 +15,9 @@ class LogViewController: UIViewController {
     }()
 
     let busyIndicator: UIActivityIndicatorView = {
-        if #available(iOS 13.0, *) {
-            let busyIndicator = UIActivityIndicatorView(style: .medium)
-            busyIndicator.hidesWhenStopped = true
-            return busyIndicator
-        } else {
-            let busyIndicator = UIActivityIndicatorView(style: .gray)
-            busyIndicator.hidesWhenStopped = true
-            return busyIndicator
-        }
+        let busyIndicator = UIActivityIndicatorView(style: .medium)
+        busyIndicator.hidesWhenStopped = true
+        return busyIndicator
     }()
 
     let paragraphStyle: NSParagraphStyle = {
@@ -41,12 +35,7 @@ class LogViewController: UIViewController {
 
     override func loadView() {
         view = UIView()
-        if #available(iOS 13.0, *) {
-            view.backgroundColor = .systemBackground
-        } else {
-            view.backgroundColor = .white
-        }
-
+        view.backgroundColor = .systemBackground
         view.addSubview(textView)
         textView.translatesAutoresizingMaskIntoConstraints = false
         NSLayoutConstraint.activate([
@@ -92,15 +81,8 @@ class LogViewController: UIViewController {
             let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
             let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
             for logEntry in fetchedLogEntries {
-                var bgColor: UIColor
-                var fgColor: UIColor
-                if #available(iOS 13.0, *) {
-                    bgColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
-                    fgColor = .label
-                } else {
-                    bgColor = self.isNextLineHighlighted ? UIColor(white: 0.88, alpha: 1.0) : UIColor.white
-                    fgColor = .black
-                }
+                let bgColor: UIColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
+                let fgColor: UIColor = .label
                 let timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
                 let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
                 richText.append(timestampText)
index b7805172ed8cb65142b822b69138c8356732fa73..eb1f91a4203382157ae73b19895a634f0a232e32 100644 (file)
@@ -11,11 +11,7 @@ class MainViewController: UISplitViewController {
 
     init() {
         let detailVC = UIViewController()
-        if #available(iOS 13.0, *) {
-            detailVC.view.backgroundColor = .systemBackground
-        } else {
-            detailVC.view.backgroundColor = .white
-        }
+        detailVC.view.backgroundColor = .systemBackground
         let detailNC = UINavigationController(rootViewController: detailVC)
 
         let masterVC = TunnelsListTableViewController()
index d32fa8ca9b10a2b39697018d86b59f9527197470..072e86a2d37fc39374f2f1dba905449690b0aad0 100644 (file)
@@ -185,11 +185,7 @@ extension SSIDOptionEditTableViewController {
     private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
         let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
         cell.message = tr("tunnelOnDemandNoSSIDs")
-        if #available(iOS 13.0, *) {
-            cell.setTextColor(.secondaryLabel)
-        } else {
-            cell.setTextColor(.gray)
-        }
+        cell.setTextColor(.secondaryLabel)
         cell.setTextAlignment(.center)
         return cell
     }
@@ -268,23 +264,8 @@ extension SSIDOptionEditTableViewController {
         #if targetEnvironment(simulator)
         completionHandler("Simulator Wi-Fi")
         #else
-        if #available(iOS 14, *) {
-            NEHotspotNetwork.fetchCurrent { hotspotNetwork in
-                completionHandler(hotspotNetwork?.ssid)
-            }
-        } else {
-            if let supportedInterfaces = CNCopySupportedInterfaces() as? [CFString] {
-                for interface in supportedInterfaces {
-                    if let networkInfo = CNCopyCurrentNetworkInfo(interface) {
-                        if let ssid = (networkInfo as NSDictionary)[kCNNetworkInfoKeySSID as String] as? String {
-                            completionHandler(!ssid.isEmpty ? ssid : nil)
-                            return
-                        }
-                    }
-                }
-            }
-
-            completionHandler(nil)
+        NEHotspotNetwork.fetchCurrent { hotspotNetwork in
+            completionHandler(hotspotNetwork?.ssid)
         }
         #endif
     }
index 85e64cea2eb825fad5f6fcbfb10f880de8cf2af2..95d4504aab1b8c7882ec3e666b2174da87025950 100644 (file)
@@ -33,11 +33,7 @@ class TunnelsListTableViewController: UIViewController {
 
     let busyIndicator: UIActivityIndicatorView = {
         let busyIndicator: UIActivityIndicatorView
-        if #available(iOS 13.0, *) {
-            busyIndicator = UIActivityIndicatorView(style: .medium)
-        } else {
-            busyIndicator = UIActivityIndicatorView(style: .gray)
-        }
+        busyIndicator = UIActivityIndicatorView(style: .medium)
         busyIndicator.hidesWhenStopped = true
         return busyIndicator
     }()
@@ -51,11 +47,7 @@ class TunnelsListTableViewController: UIViewController {
 
     override func loadView() {
         view = UIView()
-        if #available(iOS 13.0, *) {
-            view.backgroundColor = .systemBackground
-        } else {
-            view.backgroundColor = .white
-        }
+        view.backgroundColor = .systemBackground
 
         tableView.dataSource = self
         tableView.delegate = self
@@ -406,11 +398,7 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
                 (splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
             } else {
                 let detailVC = UIViewController()
-                if #available(iOS 13.0, *) {
-                    detailVC.view.backgroundColor = .systemBackground
-                } else {
-                    detailVC.view.backgroundColor = .white
-                }
+                detailVC.view.backgroundColor = .systemBackground
                 let detailNC = UINavigationController(rootViewController: detailVC)
                 splitViewController.showDetailViewController(detailNC, sender: self)
             }
index 1c37daf8010fe517d1d562885d922adcb75f8b7b..3c1b452749401b003a4395d452569a067a3ab615 100644 (file)
@@ -14,23 +14,19 @@ int main(int argc, char *argv[])
         return 2;
     uint64_t now = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
     if (![[NSData dataWithBytes:&now length:sizeof(now)] writeToURL:[containerUrl URLByAppendingPathComponent:@"login-helper-timestamp.bin"] atomically:YES])
-        return 3;
-    if (@available(macOS 10.15, *)) {
-        NSCondition *condition = [[NSCondition alloc] init];
-        NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
-        if (!appURL)
-            return 4;
-        NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration];
-        openConfiguration.activates = NO;
-        openConfiguration.addsToRecentItems = NO;
-        openConfiguration.hides = YES;
-        [NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) {
-            [condition signal];
-        }];
-        [condition wait];
-    } else {
-        [NSWorkspace.sharedWorkspace launchAppWithBundleIdentifier:appId options:NSWorkspaceLaunchWithoutActivation
-                                    additionalEventParamDescriptor:NULL launchIdentifier:NULL];
-    }
+    return 3;
+
+    NSCondition *condition = [[NSCondition alloc] init];
+    NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
+    if (!appURL)
+       return 4;
+    NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration];
+    openConfiguration.activates = NO;
+    openConfiguration.addsToRecentItems = NO;
+    openConfiguration.hides = YES;
+    [NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) {
+        [condition signal];
+    }];
+    [condition wait];
     return 0;
 }
index 8b19d16f0137410d7852dbdc139d08d767bd8c27..bc7c35760e4c0cfc68e8a9e3e98edd6d94bacef9 100644 (file)
                6FB1BD6721D2607E00A991BF /* WireGuard.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WireGuard.entitlements; sourceTree = "<group>"; };
                6FB1BD9121D4BFE600A991BF /* WireGuardNetworkExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WireGuardNetworkExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
                6FB1BD9621D4BFE700A991BF /* WireGuardNetworkExtension_macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WireGuardNetworkExtension_macOS.entitlements; sourceTree = "<group>"; };
-               6FB1BDB621D4F8B800A991BF /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/NetworkExtension.framework; sourceTree = DEVELOPER_DIR; };
+               6FB1BDB621D4F8B800A991BF /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/NetworkExtension.framework; sourceTree = DEVELOPER_DIR; };
                6FBA101321D613F30051C35F /* Application.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = "<group>"; };
                6FBA101621D655340051C35F /* StatusMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusMenu.swift; sourceTree = "<group>"; };
                6FBA103A21D6B4280051C35F /* ErrorPresenterProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorPresenterProtocol.swift; sourceTree = "<group>"; };
                                        "$(inherited)",
                                        "@executable_path/../Frameworks",
                                );
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
+                               MACOSX_DEPLOYMENT_TARGET = 12.0;
                                PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS)";
                                PRODUCT_NAME = WireGuard;
                                SDKROOT = macosx;
                                        "$(inherited)",
                                        "@executable_path/../Frameworks",
                                );
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
+                               MACOSX_DEPLOYMENT_TARGET = 12.0;
                                PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS)";
                                PRODUCT_NAME = WireGuard;
                                SDKROOT = macosx;
                                        "@executable_path/../Frameworks",
                                        "@executable_path/../../../../Frameworks",
                                );
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
+                               MACOSX_DEPLOYMENT_TARGET = 12.0;
                                PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS).network-extension";
                                PRODUCT_NAME = WireGuardNetworkExtension;
                                SDKROOT = macosx;
                                        "@executable_path/../Frameworks",
                                        "@executable_path/../../../../Frameworks",
                                );
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
+                               MACOSX_DEPLOYMENT_TARGET = 12.0;
                                PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS).network-extension";
                                PRODUCT_NAME = WireGuardNetworkExtension;
                                SDKROOT = macosx;
                                GCC_WARN_UNUSED_FUNCTION = YES;
                                GCC_WARN_UNUSED_LABEL = YES;
                                GCC_WARN_UNUSED_VARIABLE = YES;
-                               IPHONEOS_DEPLOYMENT_TARGET = 12.0;
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
+                               IPHONEOS_DEPLOYMENT_TARGET = 15.0;
+                               MACOSX_DEPLOYMENT_TARGET = 12.0;
                                MTL_ENABLE_DEBUG_INFO = YES;
                                MTL_FAST_MATH = YES;
                                ONLY_ACTIVE_ARCH = YES;
                                GCC_WARN_UNUSED_FUNCTION = YES;
                                GCC_WARN_UNUSED_LABEL = YES;
                                GCC_WARN_UNUSED_VARIABLE = YES;
-                               IPHONEOS_DEPLOYMENT_TARGET = 12.0;
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
+                               IPHONEOS_DEPLOYMENT_TARGET = 15.0;
+                               MACOSX_DEPLOYMENT_TARGET = 12.0;
                                MTL_ENABLE_DEBUG_INFO = NO;
                                MTL_FAST_MATH = YES;
                                SDKROOT = iphoneos;