Skip to content

Commit d6f1ea8

Browse files
committed
global: bump minimum OS versions
This allows us to remove a good deal of legacy cruft. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent ccc7472 commit d6f1ea8

13 files changed

+64
-159
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import PackageDescription
66
let package = Package(
77
name: "WireGuardKit",
88
platforms: [
9-
.macOS(.v10_14),
10-
.iOS(.v12)
9+
.macOS(.v12),
10+
.iOS(.v15)
1111
],
1212
products: [
1313
.library(name: "WireGuardKit", targets: ["WireGuardKit"])

Sources/Shared/Model/NETunnelProviderProtocol+Extension.swift

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,22 @@ extension NETunnelProviderProtocol {
8282
return true
8383
}
8484
#elseif os(iOS)
85-
if #available(iOS 15, *) {
86-
/* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one.
87-
* The iOS 14 ones are 96 bits, while the iOS 15 ones are 160 bits. We do this so
88-
* that we can have fast set exclusion in deleteReferences safely. */
89-
if passwordReference != nil && passwordReference!.count == 12 {
90-
var result: CFTypeRef?
91-
let ret = SecItemCopyMatching([kSecValuePersistentRef: passwordReference!,
92-
kSecReturnPersistentRef: true] as CFDictionary,
93-
&result)
94-
if ret != errSecSuccess || result == nil {
95-
return false
96-
}
97-
guard let newReference = result as? Data else { return false }
98-
if !newReference.elementsEqual(passwordReference!) {
99-
wg_log(.info, message: "Migrating iOS 14-style keychain reference to iOS 15-style keychain reference for '\(name)'")
100-
passwordReference = newReference
101-
return true
102-
}
85+
/* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one.
86+
* The iOS 14 ones are 96 bits, while the iOS 15 ones are 160 bits. We do this so
87+
* that we can have fast set exclusion in deleteReferences safely. */
88+
if passwordReference != nil && passwordReference!.count == 12 {
89+
var result: CFTypeRef?
90+
let ret = SecItemCopyMatching([kSecValuePersistentRef: passwordReference!,
91+
kSecReturnPersistentRef: true] as CFDictionary,
92+
&result)
93+
if ret != errSecSuccess || result == nil {
94+
return false
95+
}
96+
guard let newReference = result as? Data else { return false }
97+
if !newReference.elementsEqual(passwordReference!) {
98+
wg_log(.info, message: "Migrating iOS 14-style keychain reference to iOS 15-style keychain reference for '\(name)'")
99+
passwordReference = newReference
100+
return true
103101
}
104102
}
105103
#endif

Sources/WireGuardApp/UI/iOS/View/KeyValueCell.swift

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ class KeyValueCell: UITableViewCell {
99
let keyLabel = UILabel()
1010
keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
1111
keyLabel.adjustsFontForContentSizeCategory = true
12-
if #available(iOS 13.0, *) {
13-
keyLabel.textColor = .label
14-
} else {
15-
keyLabel.textColor = .black
16-
}
12+
keyLabel.textColor = .label
1713
keyLabel.textAlignment = .left
1814
return keyLabel
1915
}()
@@ -35,11 +31,7 @@ class KeyValueCell: UITableViewCell {
3531
valueTextField.autocapitalizationType = .none
3632
valueTextField.autocorrectionType = .no
3733
valueTextField.spellCheckingType = .no
38-
if #available(iOS 13.0, *) {
39-
valueTextField.textColor = .secondaryLabel
40-
} else {
41-
valueTextField.textColor = .gray
42-
}
34+
valueTextField.textColor = .secondaryLabel
4335
return valueTextField
4436
}()
4537

@@ -64,18 +56,10 @@ class KeyValueCell: UITableViewCell {
6456

6557
var isValueValid = true {
6658
didSet {
67-
if #available(iOS 13.0, *) {
68-
if isValueValid {
69-
keyLabel.textColor = .label
70-
} else {
71-
keyLabel.textColor = .systemRed
72-
}
59+
if isValueValid {
60+
keyLabel.textColor = .label
7361
} else {
74-
if isValueValid {
75-
keyLabel.textColor = .black
76-
} else {
77-
keyLabel.textColor = .red
78-
}
62+
keyLabel.textColor = .systemRed
7963
}
8064
}
8165
}

Sources/WireGuardApp/UI/iOS/View/SwitchCell.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ class SwitchCell: UITableViewCell {
1616
get { return switchView.isEnabled }
1717
set(value) {
1818
switchView.isEnabled = value
19-
if #available(iOS 13.0, *) {
20-
textLabel?.textColor = value ? .label : .secondaryLabel
21-
} else {
22-
textLabel?.textColor = value ? .black : .gray
23-
}
19+
textLabel?.textColor = value ? .label : .secondaryLabel
2420
}
2521
}
2622

Sources/WireGuardApp/UI/iOS/View/TextCell.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ class TextCell: UITableViewCell {
2828
override func prepareForReuse() {
2929
super.prepareForReuse()
3030
message = ""
31-
if #available(iOS 13.0, *) {
32-
setTextColor(.label)
33-
} else {
34-
setTextColor(.black)
35-
}
31+
setTextColor(.label)
3632
setTextAlignment(.left)
3733
}
3834
}

Sources/WireGuardApp/UI/iOS/View/TunnelEditKeyValueCell.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
3030
super.init(style: style, reuseIdentifier: reuseIdentifier)
3131

3232
copyableGesture = false
33-
if #available(iOS 13.0, *) {
34-
valueTextField.textColor = .label
35-
} else {
36-
valueTextField.textColor = .black
37-
}
33+
valueTextField.textColor = .label
3834
valueTextField.isEnabled = true
3935
valueLabelScrollView.isScrollEnabled = false
4036
valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true

Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,13 @@ class TunnelListCell: UITableViewCell {
4141
label.font = UIFont.preferredFont(forTextStyle: .caption2)
4242
label.adjustsFontForContentSizeCategory = true
4343
label.numberOfLines = 1
44-
if #available(iOS 13.0, *) {
45-
label.textColor = .secondaryLabel
46-
} else {
47-
label.textColor = .gray
48-
}
44+
label.textColor = .secondaryLabel
4945
return label
5046
}()
5147

5248
let busyIndicator: UIActivityIndicatorView = {
5349
let busyIndicator: UIActivityIndicatorView
54-
if #available(iOS 13.0, *) {
55-
busyIndicator = UIActivityIndicatorView(style: .medium)
56-
} else {
57-
busyIndicator = UIActivityIndicatorView(style: .gray)
58-
}
50+
busyIndicator = UIActivityIndicatorView(style: .medium)
5951
busyIndicator.hidesWhenStopped = true
6052
return busyIndicator
6153
}()

Sources/WireGuardApp/UI/iOS/ViewController/LogViewController.swift

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ class LogViewController: UIViewController {
1515
}()
1616

1717
let busyIndicator: UIActivityIndicatorView = {
18-
if #available(iOS 13.0, *) {
19-
let busyIndicator = UIActivityIndicatorView(style: .medium)
20-
busyIndicator.hidesWhenStopped = true
21-
return busyIndicator
22-
} else {
23-
let busyIndicator = UIActivityIndicatorView(style: .gray)
24-
busyIndicator.hidesWhenStopped = true
25-
return busyIndicator
26-
}
18+
let busyIndicator = UIActivityIndicatorView(style: .medium)
19+
busyIndicator.hidesWhenStopped = true
20+
return busyIndicator
2721
}()
2822

2923
let paragraphStyle: NSParagraphStyle = {
@@ -41,12 +35,7 @@ class LogViewController: UIViewController {
4135

4236
override func loadView() {
4337
view = UIView()
44-
if #available(iOS 13.0, *) {
45-
view.backgroundColor = .systemBackground
46-
} else {
47-
view.backgroundColor = .white
48-
}
49-
38+
view.backgroundColor = .systemBackground
5039
view.addSubview(textView)
5140
textView.translatesAutoresizingMaskIntoConstraints = false
5241
NSLayoutConstraint.activate([
@@ -92,15 +81,8 @@ class LogViewController: UIViewController {
9281
let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
9382
let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
9483
for logEntry in fetchedLogEntries {
95-
var bgColor: UIColor
96-
var fgColor: UIColor
97-
if #available(iOS 13.0, *) {
98-
bgColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
99-
fgColor = .label
100-
} else {
101-
bgColor = self.isNextLineHighlighted ? UIColor(white: 0.88, alpha: 1.0) : UIColor.white
102-
fgColor = .black
103-
}
84+
let bgColor: UIColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
85+
let fgColor: UIColor = .label
10486
let timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
10587
let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
10688
richText.append(timestampText)

Sources/WireGuardApp/UI/iOS/ViewController/MainViewController.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ class MainViewController: UISplitViewController {
1111

1212
init() {
1313
let detailVC = UIViewController()
14-
if #available(iOS 13.0, *) {
15-
detailVC.view.backgroundColor = .systemBackground
16-
} else {
17-
detailVC.view.backgroundColor = .white
18-
}
14+
detailVC.view.backgroundColor = .systemBackground
1915
let detailNC = UINavigationController(rootViewController: detailVC)
2016

2117
let masterVC = TunnelsListTableViewController()

Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,7 @@ extension SSIDOptionEditTableViewController {
185185
private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
186186
let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
187187
cell.message = tr("tunnelOnDemandNoSSIDs")
188-
if #available(iOS 13.0, *) {
189-
cell.setTextColor(.secondaryLabel)
190-
} else {
191-
cell.setTextColor(.gray)
192-
}
188+
cell.setTextColor(.secondaryLabel)
193189
cell.setTextAlignment(.center)
194190
return cell
195191
}
@@ -268,23 +264,8 @@ extension SSIDOptionEditTableViewController {
268264
#if targetEnvironment(simulator)
269265
completionHandler("Simulator Wi-Fi")
270266
#else
271-
if #available(iOS 14, *) {
272-
NEHotspotNetwork.fetchCurrent { hotspotNetwork in
273-
completionHandler(hotspotNetwork?.ssid)
274-
}
275-
} else {
276-
if let supportedInterfaces = CNCopySupportedInterfaces() as? [CFString] {
277-
for interface in supportedInterfaces {
278-
if let networkInfo = CNCopyCurrentNetworkInfo(interface) {
279-
if let ssid = (networkInfo as NSDictionary)[kCNNetworkInfoKeySSID as String] as? String {
280-
completionHandler(!ssid.isEmpty ? ssid : nil)
281-
return
282-
}
283-
}
284-
}
285-
}
286-
287-
completionHandler(nil)
267+
NEHotspotNetwork.fetchCurrent { hotspotNetwork in
268+
completionHandler(hotspotNetwork?.ssid)
288269
}
289270
#endif
290271
}

Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ class TunnelsListTableViewController: UIViewController {
3333

3434
let busyIndicator: UIActivityIndicatorView = {
3535
let busyIndicator: UIActivityIndicatorView
36-
if #available(iOS 13.0, *) {
37-
busyIndicator = UIActivityIndicatorView(style: .medium)
38-
} else {
39-
busyIndicator = UIActivityIndicatorView(style: .gray)
40-
}
36+
busyIndicator = UIActivityIndicatorView(style: .medium)
4137
busyIndicator.hidesWhenStopped = true
4238
return busyIndicator
4339
}()
@@ -51,11 +47,7 @@ class TunnelsListTableViewController: UIViewController {
5147

5248
override func loadView() {
5349
view = UIView()
54-
if #available(iOS 13.0, *) {
55-
view.backgroundColor = .systemBackground
56-
} else {
57-
view.backgroundColor = .white
58-
}
50+
view.backgroundColor = .systemBackground
5951

6052
tableView.dataSource = self
6153
tableView.delegate = self
@@ -406,11 +398,7 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
406398
(splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
407399
} else {
408400
let detailVC = UIViewController()
409-
if #available(iOS 13.0, *) {
410-
detailVC.view.backgroundColor = .systemBackground
411-
} else {
412-
detailVC.view.backgroundColor = .white
413-
}
401+
detailVC.view.backgroundColor = .systemBackground
414402
let detailNC = UINavigationController(rootViewController: detailVC)
415403
splitViewController.showDetailViewController(detailNC, sender: self)
416404
}

Sources/WireGuardApp/UI/macOS/LoginItemHelper/main.m

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,19 @@ int main(int argc, char *argv[])
1414
return 2;
1515
uint64_t now = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
1616
if (![[NSData dataWithBytes:&now length:sizeof(now)] writeToURL:[containerUrl URLByAppendingPathComponent:@"login-helper-timestamp.bin"] atomically:YES])
17-
return 3;
18-
if (@available(macOS 10.15, *)) {
19-
NSCondition *condition = [[NSCondition alloc] init];
20-
NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
21-
if (!appURL)
22-
return 4;
23-
NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration];
24-
openConfiguration.activates = NO;
25-
openConfiguration.addsToRecentItems = NO;
26-
openConfiguration.hides = YES;
27-
[NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) {
28-
[condition signal];
29-
}];
30-
[condition wait];
31-
} else {
32-
[NSWorkspace.sharedWorkspace launchAppWithBundleIdentifier:appId options:NSWorkspaceLaunchWithoutActivation
33-
additionalEventParamDescriptor:NULL launchIdentifier:NULL];
34-
}
17+
return 3;
18+
19+
NSCondition *condition = [[NSCondition alloc] init];
20+
NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
21+
if (!appURL)
22+
return 4;
23+
NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration];
24+
openConfiguration.activates = NO;
25+
openConfiguration.addsToRecentItems = NO;
26+
openConfiguration.hides = YES;
27+
[NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) {
28+
[condition signal];
29+
}];
30+
[condition wait];
3531
return 0;
3632
}

0 commit comments

Comments
 (0)