Create a new project

Last updated:

You begin by creating an initial application. Throughout this tutorial, you’ll modify and extend that starter application to create a simple application which cover all the basic features.

Set up your environment

Create Xcode project

If you don't have an Xcode project yet, create one now and save it to your local machine.

If you're new to iOS development, create a "Single View Application" or "App" (depending on your version of Xcode) for iOS. Name it how you like, e.g. "MIstarter".

This guide uses Swift as the programming language and Storyboards for creating user interfaces, so choose that for your project if you want to follow along easier.

MapsIndoors can either be installed using CocoaPods or manually.

Install MapsIndoors using CocoaPods

If you haven't already, install CocoaPods: Getting Started with CocoaPods

  • Create a file named Podfile in your project directory (same folder as your .xcodeproj file). The Podfile file defines your project's dependencies.
  • Edit the Podfile and add your dependencies. Here is an example:
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '14.0'

target 'YOUR_APPLICATION_TARGET_NAME_HERE' do

pod 'MapsIndoors', '~>3.30.0'

end
  • Save the Podfile.

  • Open a terminal and go to the directory containing the Podfile:

    cd <path-to-project>
  • Run the pod install command. This will install the APIs specified in the Podfile, along with any dependencies they may have.

  • Close Xcode, and then open (double-click) your project's .xcworkspace file to launch Xcode. From this time onwards, you must use the .xcworkspace file to open the project.

Install MapsIndoors Manually

Since MapsIndoors is dependent on Google Maps iOS SDK, you must also install this SDK, either manually, using Carthage or using CocoaPods. You should use Google Maps iOS version 4.2.0 since MapsIndoors >=3.30.0 is linked against this version.

When the Google Maps installation is completed, go through these steps to install MapsIndoors:

  • Download and unzip the latest MapsIndoors.xcframework.
  • Drag and drop the framework into your XCode project. In the dialog that pops up, choose “Copy items if needed” and make sure the framework is added to the correct target.
  • From XCode, right click the imported framework and click "Show in Finder".
  • In Finder, Locate ios-arm64 > MapsIndoors.framework > Resources > MapsIndoors.bundle, and drag the bundle into your XCode project as well. This time, make sure to uncheck “Copy items if needed”.

Add your API Credentials

Add your credentials to your AppDelegate.swift

  1. Add the following import statements:

    import GoogleMaps
    import MapsIndoors
  2. Add the following to your application(_:didFinishLaunchingWithOptions:) method:

    GMSServices.provideAPIKey(      "YOUR_GOOGLE_API_KEY")
    MapsIndoors.provideAPIKey( "YOUR_MAPSINDOORS_API_KEY",
    googleAPIKey: "YOUR_GOOGLE_API_KEY")

    Replace:

    • YOUR_GOOGLE_API_KEY with your Google API key.
    • YOUR_MAPSINDOORS_API_KEY with your MapsIndoors API key.

Next up: Show a map