Skip to content

Commit

Permalink
Merge pull request #79 from afterpay/fix-xcframework-compatibility
Browse files Browse the repository at this point in the history
Fix xcframework compatibility
  • Loading branch information
adamjcampbell authored Jul 21, 2020
2 parents 9700d5a + d8d3d04 commit 9557d07
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 33 deletions.
58 changes: 27 additions & 31 deletions Sources/Afterpay/Afterpay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,34 @@
import Foundation
import UIKit

public enum Afterpay {
/// Present Afterpay Checkout modally over the specified view controller loading your
/// generated checkout URL.
/// - Parameters:
/// - viewController: The viewController on which `UIViewController.present` will be called.
/// The Afterpay Checkout View Controller will be presented modally over this view controller
/// or it's closest parent that is able to handle the presentation.
/// - checkoutURL: The checkout URL to load generated via the /checkouts endpoint on the
/// Afterpay backend.
/// - animated: Pass true to animate the presentation; otherwise, pass false.
/// - completion: The block executed after the user has completed the checkout.
/// - result: The result of the user's completion (a success or cancellation).
public func presentCheckoutModally(
over viewController: UIViewController,
loading checkoutURL: URL,
animated: Bool = true,
completion: @escaping (_ result: CheckoutResult) -> Void
) {
var viewControllerToPresent: UIViewController = WebViewController(
checkoutUrl: checkoutURL,
completion: completion
)

/// Present Afterpay Checkout modally over the specified view controller loading your
/// generated checkout URL.
/// - Parameters:
/// - viewController: The viewController on which `UIViewController.present` will be called.
/// The Afterpay Checkout View Controller will be presented modally over this view controller
/// or it's closest parent that is able to handle the presentation.
/// - checkoutURL: The checkout URL to load generated via the /checkouts endpoint on the
/// Afterpay backend.
/// - animated: Pass true to animate the presentation; otherwise, pass false.
/// - completion: The block executed after the user has completed the checkout.
/// - result: The result of the user's completion (a success or cancellation).
public static func presentCheckoutModally(
over viewController: UIViewController,
loading checkoutURL: URL,
animated: Bool = true,
completion: @escaping (_ result: CheckoutResult) -> Void
) {
var viewControllerToPresent: UIViewController = WebViewController(
checkoutUrl: checkoutURL,
completion: completion
)

if #available(iOS 13.0, *) {
} else {
// Wrap the modal in a navigation controller to allow dismiss via a bar button item prior
// to popover modals in iOS13
viewControllerToPresent = UINavigationController(rootViewController: viewControllerToPresent)
}

viewController.present(viewControllerToPresent, animated: animated, completion: nil)
if #available(iOS 13.0, *) {
} else {
// Wrap the modal in a navigation controller to allow dismiss via a bar button item prior
// to popover modals in iOS13
viewControllerToPresent = UINavigationController(rootViewController: viewControllerToPresent)
}

viewController.present(viewControllerToPresent, animated: animated, completion: nil)
}
3 changes: 1 addition & 2 deletions Sources/Afterpay/ObjcWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import Foundation
import UIKit

@objc(APAfterpay)
@available(swift, obsoleted: 1.0, message: "This wrapper should only be used from Objective-C")
public final class AfterpayWrapper: NSObject {
public final class ObjcWrapper: NSObject {

@available(*, unavailable)
public override init() {}
Expand Down

0 comments on commit 9557d07

Please sign in to comment.