Skip To Content ArcGIS for Developers Sign In Dashboard

Overview

You will learn: how to build a simple app that displays a 2D map.

With the ArcGIS Runtime SDK for iOS, it is easy to create a native mapping app that displays a basemap. In this tutorial, you will use the iOS SDK to build a simple mapping app that we will use as a starting point for the other iOS tutorials. This tutorial demonstrates the basic SDK setup for iOS Xcode projects.

These tutorials assume you're developing with Xcode and have downloaded and installed the ArcGIS Runtime SDK for iOS to the default location. For a more detailed walk-through of these steps (and to see how to use Cocoapods instead), see Install and set up.

Before you begin

Make sure you have installed the latest version of Xcode.

Download and install the ArcGIS Runtime SDK for iOS by following the instructions at Install and set up.

You will need an ArcGIS account to download the SDK. If you haven't already, sign up for free.

Steps

Create a starter app

  1. Open Xcode and create a new iOS Swift Single View Application named ArcGIS Starter App.

Hook up the ArcGIS Runtime SDK

  1. With the project selected, under the General tab scroll down to the 'Embedded Binaries' section. Click the '+' button located in the bottom left corner of the view.

  2. Click 'Add Other...'

  3. Select framework following the path: /Users/<your-username>/Library/SDKs/ArcGIS/iOS/Frameworks/Dynamic/ArcGIS.framework

  4. Ensure 'Copy items if needed' is not selected

Add a map to your app

Now that you've created an app and included the ArcGIS Runtime SDK for iOS, the next step is to add a AGSMapView to the storyboard.

  1. Open Main.storyboard in the project navigator and add a new View to the parent view. Add constraints so the new view fills the parent view.

  2. With the new view selected, in Xcode's app menu, select View > Inspectors > Show Identity Inspector and in the Identity Inspector (top-right), set the Class attribute to AGSMapView.

  3. Import the ArcGIS SDK into ViewController.swift and add an @IBOutlet named mapView to the ViewController class.

    ...
    import UIKit
    /*** ADD ***/
    import ArcGIS
    
    class ViewController: UIViewController {
    
        /*** ADD ***/
        @IBOutlet weak var mapView: AGSMapView!
    
  4. Create a new private method to configure your map and assign it to the map view.

     private func setupMap() {
         mapView.map = AGSMap(basemapType: .navigationVector, latitude: 34.02700, longitude: -118.80543, levelOfDetail: 13)
     }
    
  5. Call your new method once the view loads.

        ...
        override func viewDidLoad() {
            super.viewDidLoad()
    
            /*** ADD ***/
            setupMap()
        }
    
  6. Open the Main.storyboard and right click on the yellow View Controller icon. Drag the mapView outlet connector to the AGSMapView.

  7. Press Command-R to run the app in the iOS Simulator.

Congratulations, you're done!

Your app should run and display the basemap. Compare your solution with our completed solution project. We will refer back to this project as the starting template for many of the iOS tutorials.

Challenge

Explore basemaps

Visit the iOS SDK documentation to learn more about the different types of basemaps available. Try some different basemap types such as .lightGrayCanvasVector, .topographicVector or .streetsWithReliefVector and pick your favorite basemap.

Change view

Try different settings for the initial view by changing the latitude, longitude, and level of detail.

Run on a device

If you have an Apple Developer account, try opening the app on a device rather than in the simulator. The Runtime SDK makes extensive use of OpenGL and the iOS simulator performs poorly for tasks that make use of the iOS device's graphics hardware.