Skip to content

Commit

Permalink
Set target deployment to iOS 15.0 (#1878)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
amy-at-kickstarter committed Nov 1, 2023
1 parent 5191fae commit 7588768
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 113 deletions.
Expand Up @@ -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?
Expand Down
Expand Up @@ -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)
}()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -581,7 +566,6 @@ private let separatorViewStyle: ViewStyle = { view in

// MARK: - ASAuthorizationControllerDelegate

@available(iOS 13, *)
extension LoginToutViewController: ASAuthorizationControllerDelegate {
public func authorizationController(
controller _: ASAuthorizationController,
Expand Down Expand Up @@ -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 {
Expand Down
@@ -1,7 +1,6 @@
import Library
import SwiftUI

@available(iOS 15.0, *)
struct MessageBannerView: View {
@Binding var viewModel: MessageBannerViewViewModel?

Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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)
])
}
}
}
@@ -1,7 +1,6 @@
import Library
import SwiftUI

@available(iOS 15.0, *)
struct ReportProjectLabelView: View {
let flagged: Bool

Expand Down Expand Up @@ -59,7 +58,6 @@ struct ReportProjectLabelView: View {
}
}

@available(iOS 15.0, *)
struct ReportProjectView_Previews: PreviewProvider {
static var previews: some View {
ReportProjectLabelView(flagged: false)
Expand Down
Expand Up @@ -6,7 +6,6 @@ enum ReportFormFocusField {
case details
}

@available(iOS 15.0, *)
struct ReportProjectFormView: View {
let projectID: String
let projectURL: String
Expand Down
Expand Up @@ -19,7 +19,6 @@ enum ReportProjectHyperLinkType: String, CaseIterable {
}
}

@available(iOS 15, *)
struct ReportProjectInfoView: View {
let projectID: String
let projectUrl: String
Expand Down Expand Up @@ -70,7 +69,6 @@ struct ReportProjectInfoView: View {

// MARK: - Views

@available(iOS 15, *)
private struct BaseRowView: View {
var item: ReportProjectInfoListItem
var isExpanded: Bool = false
Expand Down Expand Up @@ -107,7 +105,6 @@ private struct BaseRowView: View {
}
}

@available(iOS 15, *)
struct RowView: View {
var item: ReportProjectInfoListItem
let isExpanded: Bool
Expand Down
Expand Up @@ -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:
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -37,7 +36,6 @@ struct TextInputFieldModifier: ViewModifier {
}
}

@available(iOS 15.0, *)
extension View {
func currentEmail(keyboardType: UIKeyboardType = .default,
textColor: Color = Color(.ksr_support_700),
Expand Down
8 changes: 4 additions & 4 deletions Kickstarter.xcodeproj/project.pbxproj
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
Expand Up @@ -20,7 +20,7 @@ final class RemoteConfigFeatureHelpersTests: TestCase {
XCTAssertTrue(featureBlockUsersEnabled())
}
}

func testConsentManagementDialog_RemoteConfig_FeatureFlag_False() {
let mockRemoteConfigClient = MockRemoteConfigClient()
|> \.features .~ [RemoteConfigFeature.consentManagementDialogEnabled.rawValue: false]
Expand Down
1 change: 0 additions & 1 deletion Library/String+Attributed.swift
Expand Up @@ -39,7 +39,6 @@ public extension String {
}

/// Returns an AttributedString that allows us to display html <a> tags as tappable links.
@available(iOS 15, *)
func htmlToAttributedString() throws -> AttributedString {
try .init(
.init(
Expand Down
13 changes: 4 additions & 9 deletions Library/Styles/Fonts.swift
Expand Up @@ -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,
Expand Down
10 changes: 2 additions & 8 deletions Library/Styles/LoginStyles.swift
Expand Up @@ -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
Expand Down Expand Up @@ -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() }
Expand Down
1 change: 0 additions & 1 deletion Library/SwiftUI+Extensions/Text+HTML.swift
Expand Up @@ -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()
Expand Down

0 comments on commit 7588768

Please sign in to comment.