Project setup
The Navigation SDK for iOS is only available upon request. Contact Sales to get started.
This guide describes how you can set up your iOS project to use the TomTom Navigation SDK.
Before beginning, make sure you have Xcode >=16.0 (recommended version: 16.1) installed, created a new Xcode project, and set the deployment target to at least 15.0.
Adding dependencies
The Navigation SDK for iOS can be integrated into your project with CocoaPods or Swift Package Manager (SPM). To add dependencies, use the following instructions, depending on your preferred package manager:
Swift Package Manager
To incorporate each package into your project, follow these steps for the SDK packages:
- Core: tomtom-sdk-spm-core
- Navigation: tomtom-sdk-spm-navigation
Here’s how to add each package to your project:
- Click "File" > "Add Packages… / Add Package Dependencies…" in XCode.
- In the "Enter Package URL" textbox, enter the URL for the respective package mentioned previously.
- Set the "Dependency Rule" to "Exact Version."
- Ensure that you’ve selected the appropriate project where you want to add this dependency and click "Add Package".
- For test purposes, choose
TomTomSDKMapDisplayfrom the Core product list. - Once the package is successfully resolved and added to your project, you can use this package by importing its modules into your Swift files:
import TomTomSDKMapDisplay
CocoaPods
Use the CocoaPods dependency manager to integrate the TomTom SDK into your project.
We will install it as a Ruby gem. We are pinning the Ruby version with rbenv tool to manage Ruby gems.
-
Install rbenv using Homebrew with the following command:
brew install rbenv -
Initialize
rbenv. Run the following command and follow the instructions from the command’s output:rbenv init -
Load
rbenvto Z shell:echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrcThe preview command assumes that Z shell is being used. If a different shell is used, you can find commands for the most common shells in rbenv documentation.
-
Get a list of the stable Ruby versions:
rbenv install --list -
Install the Ruby version selected in the previous step. Run the following command replacing
x.y.zwith a selected version:rbenv install x.y.zThis guide has been tested with Ruby version 3.0.0, therefore we recommend using this version.
-
Switch to your project’s directory. Set a previously installed Ruby version for your project:
rbenv local x.y.zAs a result, the
.ruby-versionfile is created in your project’s directory. This file contains the Ruby version for your project. -
Install the CocoaPods dependency manager. Run the following command from your project’s directory:
gem install cocoapodsFrom now on, we assume that the CocoaPods dependency manager are accessible via the
podterminal command. -
Clone
tomtom-sdk-cocoapodspod specs repository to gain access to TomTom SDK frameworks:pod repo add-cdn tomtom-sdk-cocoapods "https://repositories.tomtom.com/artifactory/api/pods/cocoapods" -
Generate a
Podfileby running the following command in project directory:pod init -
Specify the platform and deployment target for the project. At the top of the
Podfileadd:platform :ios, '15.0' -
Specify the source of the TomTom SDK frameworks at top of the
Podfile:source 'https://repositories.tomtom.com/artifactory/api/pods/cocoapods' -
Verify that everything works as expected by adding the
TomTomSDKNavigationmodule to your project’sPodfile.1TOMTOM_SDK_VERSION = '0.71.1'23target 'YourAppTarget' do4 use_frameworks!5 pod 'TomTomSDKNavigation', TOMTOM_SDK_VERSION6end -
Update and install the dependencies by executing the following command in the project directory:
pod install --repo-update -
Once the
pod installcommand is successfully finished you should have the.xcworkspacefile in the project directory. Open the.xcworkspacefile to start working on the Xcode project.
Setup the API key on your project
- Get your TomTom API key. To find out how, refer to the How to get a TomTom API key guide.
- Create a
Keys.swiftfile in your project and replace theAPI_KEY_PLACEHOLDERwith your TomTom API Key:1struct Keys {2 static let tomtomApiKey = "API_KEY_PLACEHOLDER"3}
Storing API keys directly in the codebase, as currently done, poses significant security risks and vulnerabilities; we strongly recommend adopting a more secure method for API key storage.
Now that you’ve completed the project setup, here is what you can do next.
Build a simple navigation application
Use all relevant Navigation SDK APIs and built-in UI components to build a navigation application:
Learn more
Here are some suggestions for other things you can do: