Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit d1c0aae

Browse files
committed
Migrate to Swift 4.2
1 parent 759f6ef commit d1c0aae

18 files changed

+46
-44
lines changed

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,12 @@
617617
TargetAttributes = {
618618
B5ED78F3207E976500A8FD8C = {
619619
CreatedOnToolsVersion = 9.3;
620+
LastSwiftMigration = 1000;
620621
ProvisioningStyle = Automatic;
621622
};
622623
B5ED78FC207E976500A8FD8C = {
623624
CreatedOnToolsVersion = 9.3;
625+
LastSwiftMigration = 1000;
624626
ProvisioningStyle = Automatic;
625627
};
626628
};
@@ -1031,7 +1033,7 @@
10311033
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticator;
10321034
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
10331035
SKIP_INSTALL = YES;
1034-
SWIFT_VERSION = 4.0;
1036+
SWIFT_VERSION = 4.2;
10351037
TARGETED_DEVICE_FAMILY = "1,2";
10361038
};
10371039
name = Debug;
@@ -1055,7 +1057,7 @@
10551057
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticator;
10561058
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
10571059
SKIP_INSTALL = YES;
1058-
SWIFT_VERSION = 4.0;
1060+
SWIFT_VERSION = 4.2;
10591061
TARGETED_DEVICE_FAMILY = "1,2";
10601062
};
10611063
name = Release;
@@ -1070,7 +1072,7 @@
10701072
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
10711073
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticatorTests;
10721074
PRODUCT_NAME = "$(TARGET_NAME)";
1073-
SWIFT_VERSION = 4.0;
1075+
SWIFT_VERSION = 4.2;
10741076
TARGETED_DEVICE_FAMILY = "1,2";
10751077
};
10761078
name = Debug;
@@ -1085,7 +1087,7 @@
10851087
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
10861088
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticatorTests;
10871089
PRODUCT_NAME = "$(TARGET_NAME)";
1088-
SWIFT_VERSION = 4.0;
1090+
SWIFT_VERSION = 4.2;
10891091
TARGETED_DEVICE_FAMILY = "1,2";
10901092
};
10911093
name = Release;
@@ -1165,7 +1167,7 @@
11651167
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticator;
11661168
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
11671169
SKIP_INSTALL = YES;
1168-
SWIFT_VERSION = 4.0;
1170+
SWIFT_VERSION = 4.2;
11691171
TARGETED_DEVICE_FAMILY = "1,2";
11701172
};
11711173
name = "Release-Internal";
@@ -1180,7 +1182,7 @@
11801182
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
11811183
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticatorTests;
11821184
PRODUCT_NAME = "$(TARGET_NAME)";
1183-
SWIFT_VERSION = 4.0;
1185+
SWIFT_VERSION = 4.2;
11841186
TARGETED_DEVICE_FAMILY = "1,2";
11851187
};
11861188
name = "Release-Internal";
@@ -1260,7 +1262,7 @@
12601262
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticator;
12611263
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
12621264
SKIP_INSTALL = YES;
1263-
SWIFT_VERSION = 4.0;
1265+
SWIFT_VERSION = 4.2;
12641266
TARGETED_DEVICE_FAMILY = "1,2";
12651267
};
12661268
name = "Release-Alpha";
@@ -1275,7 +1277,7 @@
12751277
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
12761278
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressAuthenticatorTests;
12771279
PRODUCT_NAME = "$(TARGET_NAME)";
1278-
SWIFT_VERSION = 4.0;
1280+
SWIFT_VERSION = 4.2;
12791281
TARGETED_DEVICE_FAMILY = "1,2";
12801282
};
12811283
name = "Release-Alpha";

WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ import WordPressUI
126126

127127
let storyboard = UIStoryboard(name: "Login", bundle: bundle)
128128
if let controller = storyboard.instantiateInitialViewController() {
129-
if let childController = controller.childViewControllers.first as? LoginPrologueViewController {
129+
if let childController = controller.children.first as? LoginPrologueViewController {
130130
childController.loginFields.restrictToWPCom = restrictToWPCom
131131
childController.showCancel = showCancel
132132
}

WordPressAuthenticator/Extensions/String+Underline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension String {
1616
let underlineForegroundColor = underlineColor ?? foregroundColor
1717

1818
let underlinedString = NSMutableAttributedString(string: firstPart, attributes: [.foregroundColor: foregroundColor])
19-
underlinedString.append(NSAttributedString(string: underlinePart, attributes: [.underlineStyle: NSUnderlineStyle.styleSingle.rawValue, .foregroundColor: underlineForegroundColor]))
19+
underlinedString.append(NSAttributedString(string: underlinePart, attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue, .foregroundColor: underlineForegroundColor]))
2020
underlinedString.append(NSAttributedString(string: lastPart, attributes: [.foregroundColor: foregroundColor]))
2121

2222
return underlinedString

WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension WPStyleGuide {
3939
}
4040

4141
let onePasswordButton = UIButton(type: .custom)
42-
onePasswordButton.setImage(.onePasswordImage, for: UIControlState())
42+
onePasswordButton.setImage(.onePasswordImage, for: .normal)
4343
onePasswordButton.sizeToFit()
4444

4545
textField.rightView = onePasswordButton
@@ -56,7 +56,7 @@ extension WPStyleGuide {
5656
}
5757

5858
let onePasswordButton = UIButton(type: .custom)
59-
onePasswordButton.setImage(.onePasswordImage, for: UIControlState())
59+
onePasswordButton.setImage(.onePasswordImage, for: .normal)
6060
onePasswordButton.sizeToFit()
6161
onePasswordButton.setContentHuggingPriority(.required, for: .horizontal)
6262
onePasswordButton.setContentCompressionResistancePriority(.required, for: .horizontal)
@@ -88,7 +88,7 @@ extension WPStyleGuide {
8888
/// - note: iOS won't return UIFontWeightMedium for dynamic system font :(
8989
/// So instead get the dynamic font size, then ask for the non-dynamic font at that size
9090
///
91-
class func mediumWeightFont(forStyle style: UIFontTextStyle, maximumPointSize: CGFloat = WPStyleGuide.maxFontSize) -> UIFont {
91+
class func mediumWeightFont(forStyle style: UIFont.TextStyle, maximumPointSize: CGFloat = WPStyleGuide.maxFontSize) -> UIFont {
9292
let fontToGetSize = WPStyleGuide.fontForTextStyle(style)
9393
let maxAllowedFontSize = CGFloat.minimum(fontToGetSize.pointSize, maximumPointSize)
9494
return UIFont.systemFont(ofSize: maxAllowedFontSize, weight: .medium)

WordPressAuthenticator/NUX/NUXButton.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import WordPressUI
99
}
1010

1111
@objc let activityIndicator: UIActivityIndicatorView = {
12-
let indicator = UIActivityIndicatorView(activityIndicatorStyle: .white)
12+
let indicator = UIActivityIndicatorView(style: .white)
1313
indicator.hidesWhenStopped = true
1414
return indicator
1515
}()
@@ -68,7 +68,7 @@ import WordPressUI
6868
open override func awakeFromNib() {
6969
super.awakeFromNib()
7070
configureAppearance()
71-
activityIndicator.activityIndicatorViewStyle = .gray
71+
activityIndicator.style = .gray
7272
}
7373

7474
/// Setup: shorter reference for style

WordPressAuthenticator/NUX/NUXButtonViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ open class NUXButtonViewController: UIViewController {
6161

6262
private func configure(button: NUXButton?, withConfig buttonConfig: NUXButtonConfig?) {
6363
if let buttonConfig = buttonConfig, let button = button {
64-
button.setTitle(buttonConfig.title, for: UIControlState())
64+
button.setTitle(buttonConfig.title, for: .normal)
6565
button.accessibilityIdentifier = buttonConfig.accessibilityIdentifier ?? accessibilityIdentifier(for: buttonConfig.title)
6666
button.isPrimary = buttonConfig.isPrimary
6767
button.isHidden = false
@@ -161,9 +161,9 @@ extension NUXButtonViewController {
161161
containerView.addSubview(view)
162162
containerView.pinSubviewToAllEdges(view)
163163

164-
willMove(toParentViewController: parentViewController)
165-
parentViewController.addChildViewController(self)
166-
didMove(toParentViewController: parentViewController)
164+
willMove(toParent: parentViewController)
165+
parentViewController.addChild(self)
166+
didMove(toParent: parentViewController)
167167
}
168168

169169
/// Returns a new NUXButtonViewController Instance

WordPressAuthenticator/NUX/NUXKeyboardResponder.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ public extension NUXKeyboardResponder where Self: NUXViewController {
3030
/// - keyboardWillHideAction: A Selector to use for the UIKeyboardWillHideNotification observer.
3131
///
3232
func registerForKeyboardEvents(keyboardWillShowAction: Selector, keyboardWillHideAction: Selector) {
33-
NotificationCenter.default.addObserver(self, selector: keyboardWillShowAction, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
34-
NotificationCenter.default.addObserver(self, selector: keyboardWillHideAction, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
33+
NotificationCenter.default.addObserver(self, selector: keyboardWillShowAction, name: UIResponder.keyboardWillShowNotification, object: nil)
34+
NotificationCenter.default.addObserver(self, selector: keyboardWillHideAction, name: UIResponder.keyboardWillHideNotification, object: nil)
3535
}
3636

3737

3838
/// Unregisters the receiver from keyboard events.
3939
///
4040
func unregisterForKeyboardEvents() {
41-
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
42-
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
41+
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
42+
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
4343
}
4444

4545

@@ -130,8 +130,8 @@ public extension NUXKeyboardResponder where Self: NUXViewController {
130130
func keyboardFrameAndDurationFromNotification(_ notification: Foundation.Notification) -> (keyboardFrame: CGRect, animationDuration: Double)? {
131131

132132
guard let userInfo = notification.userInfo,
133-
let frame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue,
134-
let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue
133+
let frame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue,
134+
let duration = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue
135135
else {
136136
return nil
137137
}

WordPressAuthenticator/NUX/NUXLinkMailViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ class NUXLinkMailViewController: LoginViewController {
4949
@objc func localizeControls() {
5050

5151
let openMailButtonTitle = NSLocalizedString("Open Mail", comment: "Title of a button. The text should be capitalized. Clicking opens the mail app in the user's iOS device.")
52-
openMailButton?.setTitle(openMailButtonTitle, for: UIControlState())
52+
openMailButton?.setTitle(openMailButtonTitle, for: .normal)
5353
openMailButton?.setTitle(openMailButtonTitle, for: .highlighted)
5454

5555
let usePasswordTitle = NSLocalizedString("Enter your password instead.", comment: "Title of a button on the magic link screen.")
56-
usePasswordButton?.setTitle(usePasswordTitle, for: UIControlState())
56+
usePasswordButton?.setTitle(usePasswordTitle, for: .normal)
5757
usePasswordButton?.setTitle(usePasswordTitle, for: .highlighted)
5858
usePasswordButton?.titleLabel?.numberOfLines = 0
5959

WordPressAuthenticator/NUX/WPHelpIndicatorView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ open class WPHelpIndicatorView: UIView {
3030
}
3131

3232
override open func draw(_ rect: CGRect) {
33-
super.draw(UIEdgeInsetsInsetRect(rect, insets))
33+
super.draw(rect.inset(by: insets))
3434
}
3535

3636
}

WordPressAuthenticator/Signin/Login2FAViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF
5050
keyboardWillHideAction: #selector(handleKeyboardWillHide(_:)))
5151

5252
let nc = NotificationCenter.default
53-
nc.addObserver(self, selector: #selector(applicationBecameInactive), name: .UIApplicationWillResignActive, object: nil)
54-
nc.addObserver(self, selector: #selector(applicationBecameActive), name: .UIApplicationDidBecomeActive, object: nil)
53+
nc.addObserver(self, selector: #selector(applicationBecameInactive), name: UIApplication.willResignActiveNotification, object: nil)
54+
nc.addObserver(self, selector: #selector(applicationBecameActive), name: UIApplication.didBecomeActiveNotification, object: nil)
5555

5656
WordPressAuthenticator.track(.loginTwoFactorFormViewed)
5757
}
@@ -91,7 +91,7 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF
9191
verificationCodeField.placeholder = NSLocalizedString("Verification code", comment: "two factor code placeholder")
9292

9393
let submitButtonTitle = NSLocalizedString("Next", comment: "Title of a button.").localizedCapitalized
94-
submitButton?.setTitle(submitButtonTitle, for: UIControlState())
94+
submitButton?.setTitle(submitButtonTitle, for: .normal)
9595
submitButton?.setTitle(submitButtonTitle, for: .highlighted)
9696

9797
sendCodeButton.setTitle(NSLocalizedString("Text me a code instead", comment: "Button title"),

0 commit comments

Comments
 (0)