From 7588768961a8c79b6e1c5a77d22d81df2f7cdcfe Mon Sep 17 00:00:00 2001 From: amy-at-kickstarter <146007185+amy-at-kickstarter@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:30:52 -0400 Subject: [PATCH] Set target deployment to iOS 15.0 (#1878) * Update app release target to iOS 15.0 and remove all #available checks below iOS 15 * Update warning for snapshot test simulator so that it's on iOS 15.5 * Clean up all @available annotations <= iOS 15 * Remove last #available in TestCase.swift --- .../Controller/ChangeEmailView.swift | 1 - .../Controller/LoginToutViewController.swift | 43 ++++++------------ .../Views/MessageBannerView.swift | 1 - .../Controllers/PledgeViewController.swift | 6 +-- .../ProjectPageViewController.swift | 22 +++++----- .../Views/Cells/ReportProjectCell.swift | 44 +++++++++---------- .../Views/ReportProjectLabelView.swift | 2 - .../ReportProject/ReportProjectFormView.swift | 1 - .../ReportProject/ReportProjectInfoView.swift | 3 -- .../SettingsAccountViewController.swift | 9 +--- .../TextInputFieldModifiers.swift | 2 - Kickstarter.xcodeproj/project.pbxproj | 8 ++-- .../RemoteConfigFeature+HelpersTests.swift | 2 +- Library/String+Attributed.swift | 1 - Library/Styles/Fonts.swift | 13 ++---- Library/Styles/LoginStyles.swift | 10 +---- Library/SwiftUI+Extensions/Text+HTML.swift | 1 - Library/TestHelpers/TestCase.swift | 4 +- 18 files changed, 60 insertions(+), 113 deletions(-) diff --git a/Kickstarter-iOS/Features/ChangeEmail/Controller/ChangeEmailView.swift b/Kickstarter-iOS/Features/ChangeEmail/Controller/ChangeEmailView.swift index 2f41f2a37f..797b15c163 100644 --- a/Kickstarter-iOS/Features/ChangeEmail/Controller/ChangeEmailView.swift +++ b/Kickstarter-iOS/Features/ChangeEmail/Controller/ChangeEmailView.swift @@ -7,7 +7,6 @@ enum FocusField { case currentPassword } -@available(iOS 15.0, *) struct ChangeEmailView: View { @SwiftUI.Environment(\.defaultMinListRowHeight) var minListRow @FocusState private var focusField: FocusField? diff --git a/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift b/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift index 30313388f3..894753f45b 100644 --- a/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift +++ b/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift @@ -12,7 +12,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC ProcessingViewPresenting { // MARK: - Properties - @available(iOS 13.0, *) private lazy var appleLoginButton: ASAuthorizationAppleIDButton = { ASAuthorizationAppleIDButton(type: .continue, style: .black) }() @@ -112,10 +111,8 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC _ = self.backgroundImageView |> backgroundImageViewStyle - if #available(iOS 13.0, *) { - _ = self.appleLoginButton - |> roundedStyle(cornerRadius: Styles.grid(2)) - } + _ = self.appleLoginButton + |> roundedStyle(cornerRadius: Styles.grid(2)) _ = self.bringCreativeProjectsToLifeLabel |> baseLabelStyle @@ -305,9 +302,7 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC self.viewModel.outputs.attemptAppleLogin .observeForUI() .observeValues { [weak self] in - if #available(iOS 13, *) { - self?.attemptAppleLogin() - } + self?.attemptAppleLogin() } self.viewModel.outputs.showAppleErrorAlert @@ -353,13 +348,8 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC ], self.loginContextStackView) |> ksr_addArrangedSubviewsToStackView() - if #available(iOS 13.0, *) { - _ = ([self.appleLoginButton, self.fbLoginButton, self.getNotifiedLabel], self.fbLoginStackView) - |> ksr_addArrangedSubviewsToStackView() - } else { - _ = ([self.fbLoginButton, self.getNotifiedLabel], self.fbLoginStackView) - |> ksr_addArrangedSubviewsToStackView() - } + _ = ([self.appleLoginButton, self.fbLoginButton, self.getNotifiedLabel], self.fbLoginStackView) + |> ksr_addArrangedSubviewsToStackView() _ = ([self.signupButton, self.loginButton], self.emailLoginStackView) |> ksr_addArrangedSubviewsToStackView() @@ -374,21 +364,17 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC self.signupButton.heightAnchor.constraint(greaterThanOrEqualToConstant: Styles.minTouchSize.height) ]) - if #available(iOS 13.0, *) { - NSLayoutConstraint.activate([ - self.appleLoginButton.heightAnchor - .constraint(greaterThanOrEqualToConstant: Styles.minTouchSize.height) - ]) - } + NSLayoutConstraint.activate([ + self.appleLoginButton.heightAnchor + .constraint(greaterThanOrEqualToConstant: Styles.minTouchSize.height) + ]) } private func configureTargets() { - if #available(iOS 13.0, *) { - self.appleLoginButton.addTarget( - self, action: #selector(self.appleLoginButtonPressed(_:)), - for: .touchUpInside - ) - } + self.appleLoginButton.addTarget( + self, action: #selector(self.appleLoginButtonPressed(_:)), + for: .touchUpInside + ) self.fbLoginButton.addTarget( self, action: #selector(self.facebookLoginButtonPressed(_:)), for: .touchUpInside @@ -397,7 +383,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC self.signupButton.addTarget(self, action: #selector(self.signupButtonPressed), for: .touchUpInside) } - @available(iOS 13, *) private func attemptAppleLogin() { let appleIDRequest = ASAuthorizationAppleIDProvider().createRequest() |> \.requestedScopes .~ [.fullName, .email] @@ -581,7 +566,6 @@ private let separatorViewStyle: ViewStyle = { view in // MARK: - ASAuthorizationControllerDelegate -@available(iOS 13, *) extension LoginToutViewController: ASAuthorizationControllerDelegate { public func authorizationController( controller _: ASAuthorizationController, @@ -631,7 +615,6 @@ extension LoginToutViewController: SetYourPasswordViewControllerDelegate { // MARK: - ASAuthorizationControllerPresentationContextProviding -@available(iOS 13.0, *) extension LoginToutViewController: ASAuthorizationControllerPresentationContextProviding { public func presentationAnchor(for _: ASAuthorizationController) -> ASPresentationAnchor { guard let window = self.view.window else { diff --git a/Kickstarter-iOS/Features/MessageBanner/Views/MessageBannerView.swift b/Kickstarter-iOS/Features/MessageBanner/Views/MessageBannerView.swift index ca426602bd..6525af4280 100644 --- a/Kickstarter-iOS/Features/MessageBanner/Views/MessageBannerView.swift +++ b/Kickstarter-iOS/Features/MessageBanner/Views/MessageBannerView.swift @@ -1,7 +1,6 @@ import Library import SwiftUI -@available(iOS 15.0, *) struct MessageBannerView: View { @Binding var viewModel: MessageBannerViewViewModel? diff --git a/Kickstarter-iOS/Features/PledgeView/Controllers/PledgeViewController.swift b/Kickstarter-iOS/Features/PledgeView/Controllers/PledgeViewController.swift index e2bfa07937..037eca9bf5 100644 --- a/Kickstarter-iOS/Features/PledgeView/Controllers/PledgeViewController.swift +++ b/Kickstarter-iOS/Features/PledgeView/Controllers/PledgeViewController.swift @@ -538,11 +538,7 @@ final class PledgeViewController: UIViewController, let navigationController = UINavigationController(rootViewController: loginSignupViewController) let navigationBarHeight = navigationController.navigationBar.bounds.height - if #available(iOS 13.0, *) { - self.present(navigationController, animated: true) - } else { - self.presentViewControllerWithSheetOverlay(navigationController, offset: navigationBarHeight) - } + self.present(navigationController, animated: true) } private func beginSCAFlow(withClientSecret secret: String) { diff --git a/Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift b/Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift index 548f412247..c365033788 100644 --- a/Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift +++ b/Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift @@ -650,18 +650,16 @@ public final class ProjectPageViewController: UIViewController, MessageBannerVie } private func goToReportProject(projectID: String, projectUrl: String) { - if #available(iOS 15, *) { - let reportProjectInfoView = ReportProjectInfoView( - projectID: projectID, - projectUrl: projectUrl, - onSuccessfulSubmit: { [weak self] in - self?.viewModel.inputs.viewDidLoad() - } - ) - self.viewModel.inputs.showNavigationBar(false) - self.navigationController? - .pushViewController(UIHostingController(rootView: reportProjectInfoView), animated: true) - } + let reportProjectInfoView = ReportProjectInfoView( + projectID: projectID, + projectUrl: projectUrl, + onSuccessfulSubmit: { [weak self] in + self?.viewModel.inputs.viewDidLoad() + } + ) + self.viewModel.inputs.showNavigationBar(false) + self.navigationController? + .pushViewController(UIHostingController(rootView: reportProjectInfoView), animated: true) } private func goToUpdates(project: Project) { diff --git a/Kickstarter-iOS/Features/ProjectPage/Views/Cells/ReportProjectCell.swift b/Kickstarter-iOS/Features/ProjectPage/Views/Cells/ReportProjectCell.swift index eb377cc143..d35c838a1f 100644 --- a/Kickstarter-iOS/Features/ProjectPage/Views/Cells/ReportProjectCell.swift +++ b/Kickstarter-iOS/Features/ProjectPage/Views/Cells/ReportProjectCell.swift @@ -37,29 +37,27 @@ internal final class ReportProjectCell: UITableViewCell, ValueCell { } private func setupReportProjectLabelView(projectFlagged: Bool) { - if #available(iOS 15.0, *) { - DispatchQueue.main.async { - let hostingController = - UIHostingController(rootView: ReportProjectLabelView(flagged: projectFlagged)) - - hostingController.view.translatesAutoresizingMaskIntoConstraints = false - hostingController.view.backgroundColor = .clear - - self.contentView.addSubview(hostingController.view) - - let leftRightInset = self.traitCollection.isRegularRegular ? Styles.grid(16) : Styles.gridHalf(5) - - NSLayoutConstraint.activate([ - hostingController.view.topAnchor - .constraint(equalTo: self.contentView.topAnchor, constant: Styles.gridHalf(5)), - hostingController.view.bottomAnchor - .constraint(equalTo: self.contentView.bottomAnchor, constant: -Styles.gridHalf(5)), - hostingController.view.leadingAnchor - .constraint(equalTo: self.contentView.leadingAnchor, constant: leftRightInset), - hostingController.view.trailingAnchor - .constraint(equalTo: self.contentView.trailingAnchor, constant: -leftRightInset) - ]) - } + DispatchQueue.main.async { + let hostingController = + UIHostingController(rootView: ReportProjectLabelView(flagged: projectFlagged)) + + hostingController.view.translatesAutoresizingMaskIntoConstraints = false + hostingController.view.backgroundColor = .clear + + self.contentView.addSubview(hostingController.view) + + let leftRightInset = self.traitCollection.isRegularRegular ? Styles.grid(16) : Styles.gridHalf(5) + + NSLayoutConstraint.activate([ + hostingController.view.topAnchor + .constraint(equalTo: self.contentView.topAnchor, constant: Styles.gridHalf(5)), + hostingController.view.bottomAnchor + .constraint(equalTo: self.contentView.bottomAnchor, constant: -Styles.gridHalf(5)), + hostingController.view.leadingAnchor + .constraint(equalTo: self.contentView.leadingAnchor, constant: leftRightInset), + hostingController.view.trailingAnchor + .constraint(equalTo: self.contentView.trailingAnchor, constant: -leftRightInset) + ]) } } } diff --git a/Kickstarter-iOS/Features/ProjectPage/Views/ReportProjectLabelView.swift b/Kickstarter-iOS/Features/ProjectPage/Views/ReportProjectLabelView.swift index bce15280b3..dc0268ba41 100644 --- a/Kickstarter-iOS/Features/ProjectPage/Views/ReportProjectLabelView.swift +++ b/Kickstarter-iOS/Features/ProjectPage/Views/ReportProjectLabelView.swift @@ -1,7 +1,6 @@ import Library import SwiftUI -@available(iOS 15.0, *) struct ReportProjectLabelView: View { let flagged: Bool @@ -59,7 +58,6 @@ struct ReportProjectLabelView: View { } } -@available(iOS 15.0, *) struct ReportProjectView_Previews: PreviewProvider { static var previews: some View { ReportProjectLabelView(flagged: false) diff --git a/Kickstarter-iOS/Features/ReportProject/ReportProjectFormView.swift b/Kickstarter-iOS/Features/ReportProject/ReportProjectFormView.swift index fc6924cdfa..6b99a3588e 100644 --- a/Kickstarter-iOS/Features/ReportProject/ReportProjectFormView.swift +++ b/Kickstarter-iOS/Features/ReportProject/ReportProjectFormView.swift @@ -6,7 +6,6 @@ enum ReportFormFocusField { case details } -@available(iOS 15.0, *) struct ReportProjectFormView: View { let projectID: String let projectURL: String diff --git a/Kickstarter-iOS/Features/ReportProject/ReportProjectInfoView.swift b/Kickstarter-iOS/Features/ReportProject/ReportProjectInfoView.swift index 5cc20a044f..db4e2d1346 100644 --- a/Kickstarter-iOS/Features/ReportProject/ReportProjectInfoView.swift +++ b/Kickstarter-iOS/Features/ReportProject/ReportProjectInfoView.swift @@ -19,7 +19,6 @@ enum ReportProjectHyperLinkType: String, CaseIterable { } } -@available(iOS 15, *) struct ReportProjectInfoView: View { let projectID: String let projectUrl: String @@ -70,7 +69,6 @@ struct ReportProjectInfoView: View { // MARK: - Views -@available(iOS 15, *) private struct BaseRowView: View { var item: ReportProjectInfoListItem var isExpanded: Bool = false @@ -107,7 +105,6 @@ private struct BaseRowView: View { } } -@available(iOS 15, *) struct RowView: View { var item: ReportProjectInfoListItem let isExpanded: Bool diff --git a/Kickstarter-iOS/Features/SettingsAccount/Controller/SettingsAccountViewController.swift b/Kickstarter-iOS/Features/SettingsAccount/Controller/SettingsAccountViewController.swift index 987be72781..a8c88365e6 100644 --- a/Kickstarter-iOS/Features/SettingsAccount/Controller/SettingsAccountViewController.swift +++ b/Kickstarter-iOS/Features/SettingsAccount/Controller/SettingsAccountViewController.swift @@ -189,13 +189,8 @@ extension SettingsAccountViewController { case .createPassword: return CreatePasswordViewController.instantiate() case .changeEmail: - if #available(iOS 15, *) { - let changeEmailView = ChangeEmailView() - - return UIHostingController(rootView: changeEmailView) - } else { - return ChangeEmailViewController.instantiate() - } + let changeEmailView = ChangeEmailView() + return UIHostingController(rootView: changeEmailView) case .changePassword: return ChangePasswordViewController.instantiate() case .paymentMethods: diff --git a/Kickstarter-iOS/SharedViews/ViewModifiers/TextInputFieldModifiers.swift b/Kickstarter-iOS/SharedViews/ViewModifiers/TextInputFieldModifiers.swift index 92999eee10..d2c336656b 100644 --- a/Kickstarter-iOS/SharedViews/ViewModifiers/TextInputFieldModifiers.swift +++ b/Kickstarter-iOS/SharedViews/ViewModifiers/TextInputFieldModifiers.swift @@ -7,7 +7,6 @@ import SwiftUI Let's keep this file just for text field modifiers. As you can see there are several applications of the same modifier to different input field parameters (functions below). */ -@available(iOS 15.0, *) struct TextInputFieldModifier: ViewModifier { let keyboardType: UIKeyboardType let textColor: Color @@ -37,7 +36,6 @@ struct TextInputFieldModifier: ViewModifier { } } -@available(iOS 15.0, *) extension View { func currentEmail(keyboardType: UIKeyboardType = .default, textColor: Color = Color(.ksr_support_700), diff --git a/Kickstarter.xcodeproj/project.pbxproj b/Kickstarter.xcodeproj/project.pbxproj index d1c2683d61..930a9e8850 100644 --- a/Kickstarter.xcodeproj/project.pbxproj +++ b/Kickstarter.xcodeproj/project.pbxproj @@ -8822,7 +8822,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 5.11.0; MTL_ENABLE_DEBUG_INFO = NO; OTHER_LDFLAGS = "-ObjC"; @@ -9348,7 +9348,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 5.11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -9415,7 +9415,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 5.11.0; MTL_ENABLE_DEBUG_INFO = NO; OTHER_LDFLAGS = "-ObjC"; @@ -9687,7 +9687,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 5.11.0; MTL_ENABLE_DEBUG_INFO = NO; OTHER_LDFLAGS = "-ObjC"; diff --git a/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift b/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift index a8b41f12f8..5db1ca041d 100644 --- a/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift +++ b/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift @@ -20,7 +20,7 @@ final class RemoteConfigFeatureHelpersTests: TestCase { XCTAssertTrue(featureBlockUsersEnabled()) } } - + func testConsentManagementDialog_RemoteConfig_FeatureFlag_False() { let mockRemoteConfigClient = MockRemoteConfigClient() |> \.features .~ [RemoteConfigFeature.consentManagementDialogEnabled.rawValue: false] diff --git a/Library/String+Attributed.swift b/Library/String+Attributed.swift index 8749c8488c..6d83b88e33 100644 --- a/Library/String+Attributed.swift +++ b/Library/String+Attributed.swift @@ -39,7 +39,6 @@ public extension String { } /// Returns an AttributedString that allows us to display html tags as tappable links. - @available(iOS 15, *) func htmlToAttributedString() throws -> AttributedString { try .init( .init( diff --git a/Library/Styles/Fonts.swift b/Library/Styles/Fonts.swift index 5ccf85a135..07471874cd 100644 --- a/Library/Styles/Fonts.swift +++ b/Library/Styles/Fonts.swift @@ -135,15 +135,10 @@ extension UIFont { default: defaultSize = 17 } - let font: UIFont - if #available(iOS 13.0, *) { - font = UIFont.preferredFont( - forTextStyle: style, - compatibleWith: .current - ) - } else { - font = UIFont.preferredFont(forTextStyle: style) - } + let font = UIFont.preferredFont( + forTextStyle: style, + compatibleWith: .current + ) let descriptor = font.fontDescriptor return UIFont( descriptor: descriptor, diff --git a/Library/Styles/LoginStyles.swift b/Library/Styles/LoginStyles.swift index b7ca8d7954..adf74ad618 100644 --- a/Library/Styles/LoginStyles.swift +++ b/Library/Styles/LoginStyles.swift @@ -101,11 +101,8 @@ public func passwordFieldAutoFillStyle(_ textField: UITextField) -> UITextField public func newPasswordFieldAutoFillStyle(_ textField: UITextField) -> UITextField { let style = passwordFieldAutoFillStyle(textField) - if #available(iOS 12, *) { - return style - |> \.textContentType .~ .newPassword - } return style + |> \.textContentType .~ .newPassword } public let resetPasswordButtonStyle = greenButtonStyle @@ -198,11 +195,8 @@ public func tfaCodeFieldAutoFillStyle(_ textField: UITextField) -> UITextField { let style = textField |> tfaCodeFieldStyle - if #available(iOS 12, *) { - return style - |> \.textContentType .~ .oneTimeCode - } return style + |> \.textContentType .~ .oneTimeCode } public let twoFactorControllerStyle = UIViewController.lens.title %~ { _ in Strings.two_factor_title() } diff --git a/Library/SwiftUI+Extensions/Text+HTML.swift b/Library/SwiftUI+Extensions/Text+HTML.swift index e99c126ecd..46d175c377 100644 --- a/Library/SwiftUI+Extensions/Text+HTML.swift +++ b/Library/SwiftUI+Extensions/Text+HTML.swift @@ -3,7 +3,6 @@ import SwiftUI extension Text { /// Allows Text to be initialized with a string that has html. Option to sepcify a portion of the string that should be a hyperlink. - @available(iOS 15, *) init(html: String, with hyperlinks: [String]) { do { var attrString = try html.htmlToAttributedString() diff --git a/Library/TestHelpers/TestCase.swift b/Library/TestHelpers/TestCase.swift index e85feb3308..de94004849 100644 --- a/Library/TestHelpers/TestCase.swift +++ b/Library/TestHelpers/TestCase.swift @@ -91,8 +91,8 @@ internal class TestCase: XCTestCase { let supportedModels = ["iPhone10,1", "iPhone10,4"] // iPhone 8 let modelKey = "SIMULATOR_MODEL_IDENTIFIER" - guard #available(iOS 14.5, *), supportedModels.contains(ProcessInfo().environment[modelKey] ?? "") else { - fatalError("Please only test and record screenshots on an iPhone 8 simulator running iOS 14.5") + guard supportedModels.contains(ProcessInfo().environment[modelKey] ?? "") else { + fatalError("Please only test and record screenshots on an iPhone 8 simulator running iOS 15.5") } } }