Skip to content

Getting Started

In the following we will guide you through first steps to integrate a MapFragment into an iOS application and view the layout.

System Requirements

  • iOS 11.0 or above
  • Xcode 11.0 or above

Install the SDK

Sygic Maps SDK is available via CocoaPods Follow these steps to include Maps SDK framework into your project

If you did not create a project yet, create a new iOS project.

Changes that have to be done in Info.plist

Create your Podfile in your project root directory or run pod init command Your pod file should look something like this

platform :ios, '11.0'

target 'SdkMinimal' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # SDK
  pod 'SygicMaps'
end

Then run pod install command to install dependencies. Please see repository for the latest SDK version.

Get an API key

Please contact us to get an API Key.

Initialize the SDK

In majority of the examples we assume you're using online maps. To learn how to use offline maps please follow offline maps tutorial

First you have to make some changes in your Info.plist file. You have to add Privacy - Location When In Use Usage Description to request user permission to access location.

Changes that have to be done in Info.plist

Now initialize SDK in AppDelegate.swift as follows.

Caution

Please be aware that the Sygic Maps SDK initialization is asynchronous and any attempt to use any part of the SDK before initialization is finished may result in an exception and app crash.

First import Sygic Maps SDK

import SygicMaps

Add the following to your application(_:didFinishLaunchingWithOptions:) method, replacing your-app-key in the config with the one that was provided to you.

Info

Note that since version 15, the SECRET_CODE is no longer necessary and you can just leave the field blank (as an empty string).

NSDictionary* config = @{@"Authentication":
                      @{@"app_key" : @"your-app-key",
                      @"app_secret" : @""}
};

SYContext.initWithConfiguration(config)
{ (initResult, description) in
    if (initResult == .success) {
            // SDK successfully loaded. You can now start using whole SDK, including the SYMapView
            SYOnlineSession.shared().onlineMapsEnabled = true
        (self?.window?.rootViewController as? ViewController)?.initMap();
    } else {
        self.showSDKInitializationErrorAlert(description)
    }
}

Warning

The SYContext has to be deinitialized after being initialized.

That means for each time SYContext is initialized, it has to be deinitialized. The most common place to do this is when the app is going to be destroyed.

func applicationWillTerminate(_ application: UIApplication) {
    terminateSygicSDK()
}
func terminateSygicSDK() {
    SYContext.terminate()
}

Info

Sygic Maps SDK offers powerful configuration that allows you to configure many visual and behavioural aspects. To learn more please read our JSON Configuration documentation.

Upgrade from an earlier version

If you previously installed the Sygic Maps SDK for iOS from a zip file containing a static framework:

  1. Remove all references to the previous framework from your Xcode project.
  2. Follow the instructions to install the Sygic Maps SDK for iOS using CocoaPods.
  3. Make any necessary changes as a result of the upgrade. See the release notes for a list of the changes in each release.
  4. Clean and rebuild your project by selecting Product > Clean and then Product > Build.