iOS 13 compatibility guide
In this guide, you will learn how to use our Navigation UI in iOS 13. You will have an app that uses SwiftUI views when you finish, even in iOS 13.
Project setup
This guide uses the Navigation SDK for iOS, which is only available upon request. Contact us to get started.
Configure the project as described in the project setup guide.
SwiftUI views in iOS 13
This section explains how to create an empty SwiftUI application with an iOS 13 deployment target.
Add all the snippets from this tutorial to a single swift file, for example, your project’s
<ProjectName>App.swift
file.
- Create an empty launch screen storyboard file and set it to be the "Launch screen storyboard" in the target’s general settings for the application UI to be rendered full screen.
- Add the following imports to your project’s
<ProjectName>App.swift
file:import SwiftUI - Create an empty
ContentView
struct:1struct ContentView: View {2 var body: some View {3 ZStack(alignment: .bottom) {4 Text("Hello TomTom SDK!")5 }6 }7} - Add the
AppDelegate
class to present theContentView
on devices running iOS 13:1class AppDelegate: NSObject, UIApplicationDelegate {2 var window: UIWindow?34 func application(5 _ application: UIApplication,6 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil7 )8 -> Bool {9 if #available(iOS 14.0, *) {10 // TomTomSDKNavigationUseCaseApp will instantiate ContentView()11 } else {12 let window = UIWindow(frame: UIScreen.main.bounds)13 window.rootViewController = UIHostingController(14 rootView: ContentView()15 )16 self.window = window17 window.makeKeyAndVisible()18 }1920 return true21 }22} - Add the
YourApp
struct to present theMainView
on the devices running iOS 14 and newer:1@available(iOS 14.0, *)2struct YourApp: App {3 @UIApplicationDelegateAdaptor(AppDelegate.self)4 var appDelegate56 var body: some Scene {7 WindowGroup {8 ContentView()9 }10 }11} - Add the
YourAppWrapper.main()
function to define the application’s main function for both iOS 13 and iOS 14+ devices:1@main2enum YourAppWrapper {3 static func main() {4 if #available(iOS 14.0, *) {5 YourApp.main()6 } else {7 UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(AppDelegate.self))8 }9 }10}
Build and run your application. The application screen should have a "Hello TomTom SDK!" text.
Next steps
Since you have learned how to build iOS 13 apps with our SDK, here are recommendations for the next steps:
How to start turn-by-turn navigation and retrieve route progress information.
How to use the Navigation UI.
How to build a simple navigation application using the TomTom Navigation SDK.