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.
Create a new
Podfile
in your project directory (same folder as your .xcodeproj) by runningpod init <XCODEPROJECTNAME>
in Terminal.Add your dependecies to the
Podfile
as follows (replaceYOUR_APPLICATION_TARGET_NAME_HERE
with your actual target name),Add the
post_install
for Google Maps or for Mapbox Maps to the end of thePodfile
.
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
Save the
Podfile
and close Xcode.Open a terminal in the directory of the project.
cd <path-to-project>
Run
pod install
in the terminal.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
.
Add the following import statements to the top of the file:
Insert the following into the
application(_:didFinishLaunchingWithOptions:)
method. If you are usingMapbox
then provide your API Key when you add your map to the view insideviewDidLoad()
in yourViewController.swift
:
Finally, remember to replace YOUR_GOOGLE_API_KEY
with your Google API key.
Last updated