# Get Started

This guide walks you through the first steps to build apps with the HERE SDK. The HERE SDK is tailored to bring the best and freshest assets from the HERE platform to your mobile applications.

Before you begin, make sure you have read the following:

### Info

In order to start development, you need to get the HERE SDK package. It contains:

• The HERE SDK heresdk.xcframework. This is the HERE SDK binary bundle to include in your app(s).
• Several documentation assets and example apps.
• The HERE_NOTICE file that needs to be included in your app. See our open source notices.

You have two choices to get the HERE SDK package:

As a next step, choose a plan:

You can freely start using the HERE SDK with the Freemium plan. An overview of the available plans can be found on the pricing page. More details on the plans can be found in our pricing FAQs.

Depending on your plan the HERE SDK charges based on the number of transactions per month and other parameters such as monthly active users (MAU).

The HERE SDK requires two strings to authenticate your app:

• ACCESS KEY ID (AccessKeyId): A unique ID for your account.
• ACCESS KEY SECRET (AccessKeySecret): A secret key, which is shown only once after creation time. Please make sure to note it down before leaving the page.

No other credentials or tokens are needed to use the HERE SDK.

You can register and manage your app as described in the Identity & Access Management guide. You can acquire credentials for you plan either from developer.here.com or on the HERE platform portal:

• On developer.here.com, after creating your project, generate an app to obtain an access key ID and access key secret. You can either choose an existing project or Select a plan for a new project. Then scroll down to the HERE SDK product family and click Create a Key.
• Alternatively, on the HERE platform portal go to your apps page and register a new app. Once registered, you can create credentials.

### Note

Note that these credentials can be reused for the Lite and Explore Editions regardless of the platform - furthermore, you can use these credentials for more than one app. For example, they will work with all example apps you can find on GitHub. For the Navigate Edition you need to contact your HERE representative to generate a set of evaluation credentials.

When you obtain your credentials, also a here.client.id or an APP ID is shown. These IDs are not needed by the public APIs of the HERE SDK, but they can be useful when contacting the HERE support team. The APP ID is only relevant for the Lite Edition and the Explore Edition and has no use for other editions.

## Try the Example Apps

The easiest way to get started, is to try one of the many example projects that are available for the HERE SDK.

Choose an example of your choice, then:

1. Add the HERE SDK framework: Copy the folder heresdk.xcframework to the app's root folder. Note that this folder contains more files, including a Info.plist file and two folders (ios-arm64, ios-arm64_x86_64-simulator).
2. Add your HERE credentials (AccessKeyId and AccessKeySecret) to the AppDelegate.swift file of the project.

Now you are ready to open the Xcode project and you can instantly execute the app on your device or simulator.

### Note

Did you know that almost every topic of this Developer's Guide is available as executable app?

Feel free to experiment with the code of the examples. You can also follow the below guide to get a more thorough introduction on how to develop apps with the HERE SDK.

## Create a New iOS Project

As a very first step-by-step example, we will develop a "Hello Map" iOS application that shows - yes! - a map. If you want to integrate the SDK into an existing application, you can skip this step. No specific SDK code is involved here. We recommend using Xcode as the IDE. If you are new to iOS development, please follow the guides on developer.apple.com to help you get started with the first steps.

### Note

The example code for "HelloMap" is available from here.

Start Xcode (for this guide, we have used version 13.0) and Create a new Xcode project:

• For the template, it is sufficient to choose iOS => Application => Single View App.
• Click next.
• Provide a project name, e.g. "HelloMap" and select Swift as the language.
• Click next and choose an appropriate directory in which to save the project.

In newly created project select a simulator or a real device (which is recommended) as run destination of your application.

For the example below, we have kept the default orientation settings. When running the existing example apps, make sure the Deployment target is set to a version you have installed - we have used iOS 12.4.

Now, build and run the current scheme and confirm that your plain project executes as expected. If all goes well, you should see a blank view without any content.

## Say Hello Map!

Once we have a working iOS app, it's time to include the HERE SDK and to show a map on your simulator or device. Here's an overview of the next steps:

1. Integrate the HERE SDK.
2. Set required credentials.
3. Add a map view by code or by adding it to a storyboard.

### Note

While all of the functionalities of the HERE SDK are accessible from the simulator, usage of a real device is strongly recommended. The overall performance will be better, and some features like gestures are just easier to use on a multi-touch enabled hardware. The rendering of the map view is optimized for mobile device GPUs.

Let's begin with the first step to see how we can add the HERE SDK to our project.

## Integrate the HERE SDK

On developer.here.com you can find the latest release artifacts including the HERE SDK framework to include in your application (named xx.yy.zz.release_date).

Copy the heresdk.xcframework folder to your app's root folder. Note that this folder contains more files, including a Info.plist file and two folders (ios-arm64, ios-arm64_x86_64-simulator).

In Xcode, open the General settings of the App target and add the heresdk.xcframework to the Frameworks, libraries, and embedded content section (Click "+", then "Add other..." -> "Add files...").

### Note

Note that this guide is based on HERE SDK version 4.12.3.0. If your framework version is different from the version used for this guide, the steps may vary and you may need to adapt the example's source code.

When using the HERE SDK, your application must be authenticated with a set of credentials.

### Info

Tip: In the Key Concepts section you can find more ways to initialize the HERE SDK.

Once you have your credentials at hand, add your set of credentials programmatically when initializing the HERE SDK (see next step).

### Note

The credentials are not tied to the name of your app, but to the account used to obtain the credentials. This makes it possible to use the same set of credentials for multiple apps.

## Initialize the HERE SDK

The HERE SDK is not initialized automatically any longer. Instead, you can now freely decide at which point in time the HERE SDK should be initialized. Initialization happens synchronously on the main thread and takes around 100 ms.

In order to initialize the HERE SDK, execute the following method before you want to use the HERE SDK:

private func initializeHERESDK() {
// Set your credentials for the HERE SDK.
let accessKeyID = "YOUR_ACCESS_KEY_ID"
let accessKeySecret = "YOUR_ACCESS_KEY_SECRET"
let options = SDKOptions(accessKeyId: accessKeyID, accessKeySecret: accessKeySecret)
do {
try SDKNativeEngine.makeSharedInstance(options: options)
} catch let engineInstantiationError {
fatalError("Failed to initialize the HERE SDK. Cause: \(engineInstantiationError)")
}
}


Here you can insert your credentials programmatically. By calling makeSharedInstance() you initialize all what is needed to use the HERE SDK. The core class of the HERE SDK is called SDKNativeEngine. Under the hood, this instance is used by any other engine that is offered by the HERE SDK.

### Note

If you migrate from an older HERE SDK version, prior to 4.12.1.0, make sure to remove the credential tags (if any) from the plist file, at first.

Below we show an example how to call initializeHERESDK() in your AppDelegate's application(_ application:launchOptions:) method before accessing the MapView from your layout.

Similarly to initializeHERESDK(), you can also free resources by disposing the HERE SDK:

private func disposeHERESDK() {
// Free HERE SDK resources before the application shuts down.
// Usually, this should be called only on application termination.
// Afterwards, the HERE SDK is no longer usable unless it is initialized again.
SDKNativeEngine.sharedInstance = nil
}


Below we show an example how to call disposeHERESDK() in your AppDelegate's applicationWillTerminate(application:) method.

Now that we have the SDK integrated into the project and added the required credentials, we can add a new MapViewLite instance.

### Note

The map view is called 'MapViewLite' due to its special light-weighted rendering architecture that is optimized for resource-constrained devices. The HERE Rendering Engine is only available as part of the Explore Edition and the Navigate Edition.

There are two alternative ways to do this. We will first show how to add a MapViewLite programmatically, then we will show how to add a MapViewLite using a Storyboard.

Whichever method you choose, you will need to add the following module import line to your ViewController.swift file:

import heresdk


### Note

Note that multiple MapViewLite instances can be created and rendered together on one screen.

### Add the Map View Programmatically

Add a map view variable by adding the following variable declaration to your ViewController class:

var mapView: MapViewLite!


In your viewDidLoad() method, add the following code to initialize the map view:

override func viewDidLoad() {

// Initialize MapViewLite without a storyboard.
mapView = MapViewLite(frame: view.bounds)
}


This gives the MapViewLite the same size as the parent view and then adds it as a subview.

### Add the Map View to a Storyboard

You might prefer not to initialize the MapViewLite programmatically as shown above, but rather to build your UI from Xcode's Interface Builder using storyboards. In this case, you don't need to add the above lines to your view controller.

Instead, open your Main.storyboard and select the main view (nested under ViewController). In the Identity Inspector, under Custom Class, type MapViewLite. For Module, type heresdk.

Now, open the Assistant editor, control-click the map view and drag it to your ViewController to create an outlet. The outlet window will pop up; for the name, type mapView and click connect. This will add the following line to your view controller:

@IBOutlet var mapView: MapViewLite!


Now you have an IBOutlet accessible from your view controller which you can start to use. Note that this procedure does not contain any SDK specific actions. MapViewLite behaves exactly like any other UIView.

## Add the Map View using SwiftUI

Alternatively, use the map view together with SwiftUI.

The map view is a UIView subclass, you can wrap the view in a SwiftUI view that conforms to the UIViewRepresentable protocol as shown in this tutorial.

Note that SwiftUI requires iOS 13 or higher.

For this first app using the HERE SDK, we want to load one of the default map styles the SDK is shipped with.

### Note

You can also create your own fully customized map styles. HERE provides a WYSIWYG map style editor to allow you to define your own map style.

In the viewDidLoad() method of our ViewController, we add the following code to load the scene with a map style representing a normalDay map render style:

mapView.mapScene.loadScene(mapStyle: .normalDay, callback: onLoadScene)


As callback we can optionally implement a method that notifies us if loading the scene has succeeded:

func onLoadScene(errorCode: MapSceneLite.ErrorCode?) {
if let error = errorCode {
print("Error: Map scene not loaded, \(error)")
} else {
// Configure the map.
mapView.camera.setTarget(GeoCoordinates(latitude: 52.518043, longitude: 13.405991))
mapView.camera.setZoomLevel(13)
}
}


Note that the callback is called on the main thread when loading the scene is done. ErrorCode values other than nil will indicate what went wrong.

From MapViewLite, you can access the CameraLite to set some custom map parameters like the location where you want the map centered on, and a zoom level:

mapView.camera.setTarget(GeoCoordinates(latitude: 52.518043, longitude: 13.405991))
mapView.camera.setZoomLevel(13)


### Note

You can setup the CameraLite as soon as you have a MapViewLite instance available. However, you can see the changes only taking effect after the callback has finished.

As an exercise, you can try to replace the above map style with the following: .satellite. What do you get?

In addition, you can free HERE SDK resources by setting the shared instance of the SDKNativeEngine to nil, so it is no longer retained - here we can use the disposeHERESDK() method as shown above:

func applicationWillTerminate(_ application: UIApplication) {
disposeHERESDK()
}


Lastly, it is a good practice to handle the didReceiveMemoryWarning() of your view controller. The HERE SDK provides the handleLowMemory() method to safely clean up any unused resources when it is requested by the OS:

override func didReceiveMemoryWarning() {
mapView.handleLowMemory()
}


Now, it's time to build and run the app. If all goes well, you should see a HERE map covering the whole area of the screen. Congratulations, you have just mastered your first steps in using the HERE SDK for iOS.

## Prepare your App for Distribution

The HERE SDK framework is a fat binary, built for device (arm64) and simulator (x86_64). Therefore it contains both architectures. This allows easy deployment on a simulator and on a real device.

Since the HERE SDK framework conforms to Apple's XCFramework bundle type (XCFW), it is ready to be used for the distribution of your app. As it is the practice, in Xcode you have to select a development team to sign your app, select a Generic iOS Device and select Product -> Archive.

### Note

An Apple Developer Account is needed when you plan to distribute your app on a real device or share with others, for example, to publish it on Apple's App Store. Without an Apple Developer Account you can run it on an iOS simulator. Alternatively, create Xcode 'Free Provisioning' (Personal Team) profile, which can be used to try your application on a real device. Note that this profile is valid only for limited time.

## Troubleshooting

When you run into trouble, please make sure to first check the minimum requirements and the supported devices.

• I see only a blank white map: Make sure that your HERE credentials are valid and set as described in the Get Started section above. Also, make sure that your device is able to make an internet connection. With slower internet connections, it may take a while until you see the first map tiles loaded. Please also make sure that your device time is set correctly. In rare cases, a wrongly set device time can lead to authentication issues with some backend services.
• In the logs I see "No map content will be displayed until valid config is provided.": Make sure that your code is really calling loadScene().
• Xcode complains that MapViewLite is not known: Make sure to integrate the HERE SDK framework as described in the Get Started section above.
• Xcode doesn't load the module definition for heresdk: This is a Xcode SourceKit error known as rdar://42087654. Make sure to integrate the HERE SDK framework as described in the Get Started section above. Also ensure that path to your project and framework doesn't contain space symbols.
• Xcode does not compile my project for simulators. I am using a computer with a M1 chip. You are using a HERE SDK version below 4.9.2.0. Try to use a newer HERE SDK version or run in Rosetta mode by excluding the arm64 architecture for "Any iOS Simulator SDK" in the Build Settings/Architectures/Excluded Architectures/Debug setting within Xcode. Select this option in the "TARGETS" settings. Note that this may slightly slow down the performance when running the simulator.
• I see no map and/or my HERE SDK calls do nothing: If you see the following log message "These credentials do not authorize access" then your credentials are not valid. Make sure you use a working set of credentials. Credentials from the 3.x editions are not compatible. Credentials from the Lite Edition or Explore Edition are not compatible with the Navigate Edition.

## Need Help?

If you need assistance with this or any other HERE product, select one of the following options.

• If you have a HERE representative, contact them when you have questions/issues.