App: bump minimum OS versions

This allows us to remove a good deal of legacy cruft.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2023-02-14 15:31:52 +01:00
parent ccc7472fd7
commit 901fe1cf58
13 changed files with 64 additions and 159 deletions

View File

@ -6,8 +6,8 @@ import PackageDescription
let package = Package( let package = Package(
name: "WireGuardKit", name: "WireGuardKit",
platforms: [ platforms: [
.macOS(.v10_14), .macOS(.v12),
.iOS(.v12) .iOS(.v15)
], ],
products: [ products: [
.library(name: "WireGuardKit", targets: ["WireGuardKit"]) .library(name: "WireGuardKit", targets: ["WireGuardKit"])

View File

@ -82,7 +82,6 @@ extension NETunnelProviderProtocol {
return true return true
} }
#elseif os(iOS) #elseif os(iOS)
if #available(iOS 15, *) {
/* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one. /* 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 * 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. */ * that we can have fast set exclusion in deleteReferences safely. */
@ -101,7 +100,6 @@ extension NETunnelProviderProtocol {
return true return true
} }
} }
}
#endif #endif
return false return false
} }

View File

@ -9,11 +9,7 @@ class KeyValueCell: UITableViewCell {
let keyLabel = UILabel() let keyLabel = UILabel()
keyLabel.font = UIFont.preferredFont(forTextStyle: .body) keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
keyLabel.adjustsFontForContentSizeCategory = true keyLabel.adjustsFontForContentSizeCategory = true
if #available(iOS 13.0, *) {
keyLabel.textColor = .label keyLabel.textColor = .label
} else {
keyLabel.textColor = .black
}
keyLabel.textAlignment = .left keyLabel.textAlignment = .left
return keyLabel return keyLabel
}() }()
@ -35,11 +31,7 @@ class KeyValueCell: UITableViewCell {
valueTextField.autocapitalizationType = .none valueTextField.autocapitalizationType = .none
valueTextField.autocorrectionType = .no valueTextField.autocorrectionType = .no
valueTextField.spellCheckingType = .no valueTextField.spellCheckingType = .no
if #available(iOS 13.0, *) {
valueTextField.textColor = .secondaryLabel valueTextField.textColor = .secondaryLabel
} else {
valueTextField.textColor = .gray
}
return valueTextField return valueTextField
}() }()
@ -64,19 +56,11 @@ class KeyValueCell: UITableViewCell {
var isValueValid = true { var isValueValid = true {
didSet { didSet {
if #available(iOS 13.0, *) {
if isValueValid { if isValueValid {
keyLabel.textColor = .label keyLabel.textColor = .label
} else { } else {
keyLabel.textColor = .systemRed keyLabel.textColor = .systemRed
} }
} else {
if isValueValid {
keyLabel.textColor = .black
} else {
keyLabel.textColor = .red
}
}
} }
} }

View File

@ -16,11 +16,7 @@ class SwitchCell: UITableViewCell {
get { return switchView.isEnabled } get { return switchView.isEnabled }
set(value) { set(value) {
switchView.isEnabled = value switchView.isEnabled = value
if #available(iOS 13.0, *) {
textLabel?.textColor = value ? .label : .secondaryLabel textLabel?.textColor = value ? .label : .secondaryLabel
} else {
textLabel?.textColor = value ? .black : .gray
}
} }
} }

View File

@ -28,11 +28,7 @@ class TextCell: UITableViewCell {
override func prepareForReuse() { override func prepareForReuse() {
super.prepareForReuse() super.prepareForReuse()
message = "" message = ""
if #available(iOS 13.0, *) {
setTextColor(.label) setTextColor(.label)
} else {
setTextColor(.black)
}
setTextAlignment(.left) setTextAlignment(.left)
} }
} }

View File

@ -30,11 +30,7 @@ class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
copyableGesture = false copyableGesture = false
if #available(iOS 13.0, *) {
valueTextField.textColor = .label valueTextField.textColor = .label
} else {
valueTextField.textColor = .black
}
valueTextField.isEnabled = true valueTextField.isEnabled = true
valueLabelScrollView.isScrollEnabled = false valueLabelScrollView.isScrollEnabled = false
valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true

View File

@ -41,21 +41,13 @@ class TunnelListCell: UITableViewCell {
label.font = UIFont.preferredFont(forTextStyle: .caption2) label.font = UIFont.preferredFont(forTextStyle: .caption2)
label.adjustsFontForContentSizeCategory = true label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 1 label.numberOfLines = 1
if #available(iOS 13.0, *) {
label.textColor = .secondaryLabel label.textColor = .secondaryLabel
} else {
label.textColor = .gray
}
return label return label
}() }()
let busyIndicator: UIActivityIndicatorView = { let busyIndicator: UIActivityIndicatorView = {
let busyIndicator: UIActivityIndicatorView let busyIndicator: UIActivityIndicatorView
if #available(iOS 13.0, *) {
busyIndicator = UIActivityIndicatorView(style: .medium) busyIndicator = UIActivityIndicatorView(style: .medium)
} else {
busyIndicator = UIActivityIndicatorView(style: .gray)
}
busyIndicator.hidesWhenStopped = true busyIndicator.hidesWhenStopped = true
return busyIndicator return busyIndicator
}() }()

View File

@ -15,15 +15,9 @@ class LogViewController: UIViewController {
}() }()
let busyIndicator: UIActivityIndicatorView = { let busyIndicator: UIActivityIndicatorView = {
if #available(iOS 13.0, *) {
let busyIndicator = UIActivityIndicatorView(style: .medium) let busyIndicator = UIActivityIndicatorView(style: .medium)
busyIndicator.hidesWhenStopped = true busyIndicator.hidesWhenStopped = true
return busyIndicator return busyIndicator
} else {
let busyIndicator = UIActivityIndicatorView(style: .gray)
busyIndicator.hidesWhenStopped = true
return busyIndicator
}
}() }()
let paragraphStyle: NSParagraphStyle = { let paragraphStyle: NSParagraphStyle = {
@ -41,12 +35,7 @@ class LogViewController: UIViewController {
override func loadView() { override func loadView() {
view = UIView() view = UIView()
if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
view.addSubview(textView) view.addSubview(textView)
textView.translatesAutoresizingMaskIntoConstraints = false textView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
@ -92,15 +81,8 @@ class LogViewController: UIViewController {
let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body) let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1) let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
for logEntry in fetchedLogEntries { for logEntry in fetchedLogEntries {
var bgColor: UIColor let bgColor: UIColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
var fgColor: UIColor let fgColor: UIColor = .label
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 timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle]) 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]) let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
richText.append(timestampText) richText.append(timestampText)

View File

@ -11,11 +11,7 @@ class MainViewController: UISplitViewController {
init() { init() {
let detailVC = UIViewController() let detailVC = UIViewController()
if #available(iOS 13.0, *) {
detailVC.view.backgroundColor = .systemBackground detailVC.view.backgroundColor = .systemBackground
} else {
detailVC.view.backgroundColor = .white
}
let detailNC = UINavigationController(rootViewController: detailVC) let detailNC = UINavigationController(rootViewController: detailVC)
let masterVC = TunnelsListTableViewController() let masterVC = TunnelsListTableViewController()

View File

@ -185,11 +185,7 @@ extension SSIDOptionEditTableViewController {
private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell { private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
let cell: TextCell = tableView.dequeueReusableCell(for: indexPath) let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
cell.message = tr("tunnelOnDemandNoSSIDs") cell.message = tr("tunnelOnDemandNoSSIDs")
if #available(iOS 13.0, *) {
cell.setTextColor(.secondaryLabel) cell.setTextColor(.secondaryLabel)
} else {
cell.setTextColor(.gray)
}
cell.setTextAlignment(.center) cell.setTextAlignment(.center)
return cell return cell
} }
@ -268,24 +264,9 @@ extension SSIDOptionEditTableViewController {
#if targetEnvironment(simulator) #if targetEnvironment(simulator)
completionHandler("Simulator Wi-Fi") completionHandler("Simulator Wi-Fi")
#else #else
if #available(iOS 14, *) {
NEHotspotNetwork.fetchCurrent { hotspotNetwork in NEHotspotNetwork.fetchCurrent { hotspotNetwork in
completionHandler(hotspotNetwork?.ssid) 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)
}
#endif #endif
} }
} }

View File

@ -33,11 +33,7 @@ class TunnelsListTableViewController: UIViewController {
let busyIndicator: UIActivityIndicatorView = { let busyIndicator: UIActivityIndicatorView = {
let busyIndicator: UIActivityIndicatorView let busyIndicator: UIActivityIndicatorView
if #available(iOS 13.0, *) {
busyIndicator = UIActivityIndicatorView(style: .medium) busyIndicator = UIActivityIndicatorView(style: .medium)
} else {
busyIndicator = UIActivityIndicatorView(style: .gray)
}
busyIndicator.hidesWhenStopped = true busyIndicator.hidesWhenStopped = true
return busyIndicator return busyIndicator
}() }()
@ -51,11 +47,7 @@ class TunnelsListTableViewController: UIViewController {
override func loadView() { override func loadView() {
view = UIView() view = UIView()
if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
tableView.dataSource = self tableView.dataSource = self
tableView.delegate = self tableView.delegate = self
@ -406,11 +398,7 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
(splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false) (splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
} else { } else {
let detailVC = UIViewController() let detailVC = UIViewController()
if #available(iOS 13.0, *) {
detailVC.view.backgroundColor = .systemBackground detailVC.view.backgroundColor = .systemBackground
} else {
detailVC.view.backgroundColor = .white
}
let detailNC = UINavigationController(rootViewController: detailVC) let detailNC = UINavigationController(rootViewController: detailVC)
splitViewController.showDetailViewController(detailNC, sender: self) splitViewController.showDetailViewController(detailNC, sender: self)
} }

View File

@ -15,7 +15,7 @@ int main(int argc, char *argv[])
uint64_t now = clock_gettime_nsec_np(CLOCK_UPTIME_RAW); 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]) if (![[NSData dataWithBytes:&now length:sizeof(now)] writeToURL:[containerUrl URLByAppendingPathComponent:@"login-helper-timestamp.bin"] atomically:YES])
return 3; return 3;
if (@available(macOS 10.15, *)) {
NSCondition *condition = [[NSCondition alloc] init]; NSCondition *condition = [[NSCondition alloc] init];
NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId]; NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
if (!appURL) if (!appURL)
@ -28,9 +28,5 @@ int main(int argc, char *argv[])
[condition signal]; [condition signal];
}]; }];
[condition wait]; [condition wait];
} else {
[NSWorkspace.sharedWorkspace launchAppWithBundleIdentifier:appId options:NSWorkspaceLaunchWithoutActivation
additionalEventParamDescriptor:NULL launchIdentifier:NULL];
}
return 0; return 0;
} }

View File

@ -380,7 +380,7 @@
6FB1BD6721D2607E00A991BF /* WireGuard.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WireGuard.entitlements; sourceTree = "<group>"; }; 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; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 6FBA103A21D6B4280051C35F /* ErrorPresenterProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorPresenterProtocol.swift; sourceTree = "<group>"; };
@ -1626,7 +1626,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.14; MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS)"; PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS)";
PRODUCT_NAME = WireGuard; PRODUCT_NAME = WireGuard;
SDKROOT = macosx; SDKROOT = macosx;
@ -1647,7 +1647,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.14; MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS)"; PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS)";
PRODUCT_NAME = WireGuard; PRODUCT_NAME = WireGuard;
SDKROOT = macosx; SDKROOT = macosx;
@ -1668,7 +1668,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
"@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_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS).network-extension";
PRODUCT_NAME = WireGuardNetworkExtension; PRODUCT_NAME = WireGuardNetworkExtension;
SDKROOT = macosx; SDKROOT = macosx;
@ -1691,7 +1691,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
"@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_BUNDLE_IDENTIFIER = "$(APP_ID_MACOS).network-extension";
PRODUCT_NAME = WireGuardNetworkExtension; PRODUCT_NAME = WireGuardNetworkExtension;
SDKROOT = macosx; SDKROOT = macosx;
@ -1787,8 +1787,8 @@
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MACOSX_DEPLOYMENT_TARGET = 10.14; MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
@ -1850,8 +1850,8 @@
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MACOSX_DEPLOYMENT_TARGET = 10.14; MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;