Files
purchases-ios/Sources/Support/DebugUI/DebugViewController.swift
T
Rick d09d1b335a Removed support for Swift 5.7 and removed related Swift version checks (#6142)
* Remove M1 base image + test with installing simulator runtime on xcode 14.3.1

* Comment out other jobs for testing

* Added SnapshotTestingStub Package.swift for Swift 5.8 when running on CircleCI with Xcode 14.3.1

* Re-add rosetta step for iOS 13 simulators

* Fix compilation errors targeting iOS 13 because of SKTesting API not being available

* Reverting temporary commenting out CircleCI jobs

* Removed iOS 13 test support since it was only used for generating snapshots, which failed

* Removed M1 specific Mint dependency from CircleCI config

* Simplified CircleCI config by removing macos 12.6 executer since it's no longer used

* Remove last mention of old macos executor

* Removed the validate Package.swift file for Swift 5.7 build step

* Removed iOS 14 test from default build and run

* Removed support for Swift 5.7 and removed related Swift version checks
2026-01-28 08:21:24 +01:00

89 lines
2.5 KiB
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// DebugViewController.swift
//
// Created by Nacho Soto on 6/12/23.
import Foundation
#if DEBUG && os(iOS)
import SwiftUI
import UIKit
/// A view controller which allows debugging the current SDK setup.
///
/// You can present this yourself, or use `UIViewController.presentDebugRevenueCatOverlay`
/// for a default presentation using `UISheetPresentationController`.
///
/// - Seealso: `View.debugRevenueCatOverlay` for `SwiftUI`.
@available(iOS 16.0, *)
@objc(RCDebugViewController)
public final class DebugViewController: UIViewController {
private lazy var hostingController: UIHostingController<DebugSwiftUIRootView> = {
.init(rootView: .init())
}()
// swiftlint:disable:next missing_docs
public init() {
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override func loadView() {
super.loadView()
self.addChild(self.hostingController)
self.view.addSubview(self.hostingController.view)
self.hostingController.didMove(toParent: self)
}
public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
self.hostingController.view.frame = self.view.bounds
}
}
@available(iOS 16.0, *)
extension UIViewController {
/// Presents a bottom sheet overlay on top of the current view controller
/// which allows debugging the current SDK setup.
///
/// - Seealso: `DebugViewController`.
/// - Seealso: `View.debugRevenueCatOverlay` for `SwiftUI`.
@objc(rc_presentDebugRevenueCatOverlayAnimated:)
public func presentDebugRevenueCatOverlay(animated: Bool = true) {
let controller = DebugViewController()
if let sheet = controller.sheetPresentationController {
sheet.detents = [
.custom(resolver: { context in context.maximumDetentValue * 0.2 }),
.medium(),
.large()
]
sheet.largestUndimmedDetentIdentifier = .medium
sheet.preferredCornerRadius = DebugSwiftUIRootView.cornerRadius
sheet.prefersGrabberVisible = true
}
self.present(controller, animated: animated)
}
}
#endif