Project setup

VERSION 0.45.0

The Navigation SDK for iOS is only available upon request. Contact us 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 13 or 14 installed, created a new Xcode project, and set the deployment target to at least 13.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:

Here’s how to add each package to your project:

  1. Click "File" > "Add Packages… / Add Package Dependencies…​" in XCode.
  2. In the "Enter Package URL" textbox, enter the URL for the respective package mentioned previously.
  3. Set the "Dependency Rule" to "Exact Version."
  4. Ensure that you’ve selected the appropriate project where you want to add this dependency and click "Add Package".
  5. For test purposes, choose TomTomSDKMapDisplay from the Core product list.
  6. 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 and the cocoapods-art plugin to integrate the TomTom SDK into your project.

In this guide, we are using the cocoapods-art tool. We will install it as a Ruby gem. We are pinning the Ruby version with rbenv tool to manage Ruby gems.

  1. Install rbenv using Homebrew with the following command:

    brew install rbenv
  2. Initialize rbenv. Run the following command and follow the instructions from the command’s output:

    rbenv init
  3. Load rbenv to Z shell:

    echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc

    The 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.

  4. Get a list of the stable Ruby versions:

    rbenv install --list
  5. Install the Ruby version selected in the previous step. Run the following command replacing x.y.z with a selected version:

    rbenv install x.y.z

    This guide has been tested with Ruby version 3.0.0, therefore we recommend using this version.

  6. Switch to your project’s directory. Set a previously installed Ruby version for your project:

    rbenv local x.y.z

    As a result, the .ruby-version file is created in your project’s directory. This file contains the Ruby version for your project.

  7. Install the CocoaPods dependency manager. Run the following command from your project’s directory:

    gem install cocoapods
  8. Install the cocoapods-art plugin. Run the following command from your project’s directory:

    gem install cocoapods-art

    From now on, we assume that the CocoaPods dependency manager and the cocoapods-art plugin are accessible via the pod terminal command.

  9. Clone tomtom-sdk-cocoapods pod specs repository to gain access to TomTom SDK frameworks by using the cocoapods-art plugin:

    pod repo-art add tomtom-sdk-cocoapods "https://repositories.tomtom.com/artifactory/api/pods/cocoapods"
  10. Generate a Podfile by running the following command in project directory:

    pod init
  11. Specify the platform and deployment target for the project. At the top of the Podfile add:

    platform :ios, '13.0'
  12. Specify the source of the TomTom SDK frameworks at top of the Podfile:

    1plugin 'cocoapods-art', :sources => [
    2 'tomtom-sdk-cocoapods'
    3]
  13. Verify that everything works as expected by adding the TomTomSDKNavigation module to your project’s Podfile.

    1TOMTOM_SDK_VERSION = '0.45.0'
    2
    3target 'YourAppTarget' do
    4 use_frameworks!
    5 pod 'TomTomSDKNavigation', TOMTOM_SDK_VERSION
    6end
  14. Update and install the dependencies by executing the following command in the project directory:

    pod install --repo-update
  15. Once the pod install command is successfully finished you should have the .xcworkspace file in the project directory. Open the .xcworkspace file to start working on the Xcode project.

Setup the API key on your project

  1. Get your TomTom API key from the TomTom Developer Portal. To learn how, refer to the following guide: How to get a TomTom API key.
  2. Create a Keys.swift file in your project and replace the API_KEY_PLACEHOLDER with your TomTom API Key:
    1struct Keys {
    2 static let ttAPIKey = "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: