Set Up Your Environment

Now that you have taken care of all the preliminary issues, we can start building the app. Throughout this guide, you will continously modify this project to extend its functionality to cover a number of basic features.

Due to a bug in CocoaPods it is necessary to include the post_install hook in your Podfile. The post_install is different depending on if you use Google Maps or Mapbox Maps:

Create an Xcode Project

We recommend using Xcode for following along. For this guide we will be using Xcode 14.2. Note that an iOS mobile device is not required, as Xcode allows the use of a simulator.

We start off by creating an Xcode project using the App template:

For the project settings, you can call it anything you like, however ensure the following settings are set to follow along easier:

  • Interface: Storyboard

  • Language: Swift

You should now have a project folder with the following files:

For the sake of simplicity we will only be operating on these pre-generated files throughout the guide.

Installing the MapsIndoors SDK

MapsIndoors can be installed using CocoaPods (Getting Started with CocoaPods) or you can install the XCFrameworks manually if using Google Maps.

  1. Create a new Podfile in your project directory (same folder as your .xcodeproj) by running pod init <XCODEPROJECTNAME> in Terminal.

  2. Add your dependecies to the Podfile as follows (replace YOUR_APPLICATION_TARGET_NAME_HERE with your actual target name),

    source 'https://github.com/CocoaPods/Specs.git'
    
    platform :ios, '15.0' # Replace 15.0 with you iOS Minimum Deployment Target
    
    target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
      use_frameworks!
    
      # Remove the comment mark to use your map specific MapsIndoors pod
      # pod MapsIndoorsGoogleMaps, '~> 4.3'
      # or
      # pod MapsIndoorsMapbox, '~> 4.3'
    end
  3. Add the post_install for Google Maps or for Mapbox Maps to the end of the Podfile.

In the line containing pod 'MapsIndoors<MapEngine>', '~> 4.3', where it currently says 4.3, be sure to replace this number with whatever the latest minor version of the iOS SDK is.

If you're using Mapbox, make sure to configure your secret token in order to download the required dependencies from Mapbox when running pod install: https://docs.mapbox.com/ios/maps/guides/install/#configure-credentials

  1. Save the Podfile and close Xcode.

  2. Open a terminal in the directory of the project. cd <path-to-project>

  3. Run pod install in the terminal.

  4. From this time onwards, use the .xcworkspace file to open the project.

This "Getting Started" guide is created using a specific version of the SDK. When moving beyond the "Getting Started" guide, please be sure to use the latest version of the SDK.

Adding API Credentials

Open back up the project and navigate to the file AppDelegate.swift.

  1. Add the following import statements to the top of the file:

import GoogleMaps  
import MapsIndoorsCore
  1. Insert the following into the application(_:didFinishLaunchingWithOptions:) method. If you are using Mapbox then provide your API Key when you add your map to the view inside viewDidLoad() in your ViewController.swift:

 GMSServices.provideAPIKey(`YOUR_GOOGLE_API_KEY`)

Finally, remember to replace YOUR_GOOGLE_API_KEY with your Google API key.

Last updated