Assuming you are using Swift, you can use the if #available conditional to check branch your code between different iOS versions that support something your minimum deployment target does not. You will also need to annotate any types that requires iOS versions higher than your minimum deployment target with the @available macro. For example, suppose you want to create ExampleView and ExampleViewController for in SwiftUI (iOS 13+) and UIKit (iOS 11 and iOS 12), you can do the following:
@available(iOS 13.0, *)
struct ExampleView : View {
/* ... */
}
class ExampleViewController : UIViewController {
/* ...	*/
}
/* Branching between SwiftUI vs UIKit based on iOS versioning */
let destinationViewController: UIViewController
if #available(iOS 13.0, *) {
destinationViewController = UIHostingController(rootView: ExampleView())
} else {
destinationViewController = ExampleViewController()
}
self.present(destinationViewController, animated: true, completion: nil)
Similarly, if you use Objective-C, you can do the following:
if (@available(iOS 13.0, *)) {
/* ... using APIs for iOS 13 and above. */
} else {
/* ... fallback on iOS 12 and below */
}
Anyone running iOS 12 and below will see ExampleViewController, whereas anyone on iOS 13 and above will see the SwiftUI view.