5.1. NextGIS iOS SDK

5.1.1. Intro

NextGIS iOS SDK is a set of libraries used to support work with geodata in mobile applications for iPhone and iPad. The SDK includes:

The nextgis_datastore library is written in С++11 and based on GDAL. The library supports the following functionality:

  • create, modify and delete geodata (raster and vector)
  • edit vector geodata (modify geometry and attributes)
  • geodata management (copy, move, various formats import/export, etc.)
  • geodata rendering as maps using OpenGL/OpenGL ES
  • utility functions (network requests, oAuth2, json)
  • nextgis.com/NextGIS Web integration (under development)

The library has С API and bindings to other programming languages using swig.

The ios_maplib library is written in Swift and acts as easy wrapper around C API nextgis_datastore.

5.1.2. Install

To use SDK Xcode 8 or higher required. Also the Carthage utility required. Carthage is intended to be the simplest way to add frameworks to your Cocoa application. To install Carthage follow instruction at Cathage site.

In your project folder create Cartfile with following text:

github "nextgis/ios_maplib"

In terminal execute command:

carthage update --platform "iOS"

The command will download and install all necessary components.

5.1.3. Add to project

To display current location on the map you need to add to Info.plist following pair fr key-value with String type:

Privacy - Location When In Use Usage Description | String | Shows your location on the map

In your project General settings tab in Linked Frameworks and Libraries section, drag & drop``ngstore.framework`` and ngmaplib.framework from Carthage/Build/iOS folder.


Pic. 5.1. Linked Frameworks and Libraries section in General settings tab.

Next you need to setup copying of ngstore.framework and ngmaplib.framework to building directory. In Build Phases tab click the + icon and in context menu select New Run Script Phase. In Run Script section add following text to the script area below the Shell:

/usr/local/bin/carthage copy-frameworks

Next add following lines to Input Files field:


Pic. 5.2. Build Phases tab.

The details see in Carthage documentaion.

The library was build with disabled bitcode option, so you need to disable it in your project as well. In your project settings select Build Settings tab and set option Enable bitcode NO for both build types (Debug and Release).


Pic. 5.3. Build Settings tab.

In the end add to your View controller the GLK View and set as a custom class MapView class from ngmaplib module or some derived class.


Pic. 5.4. Map view form setup.

The SDK API can be found in documentation.

See demo projects at this page.