Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setup Mapnik iOS SDK v2.2.0

Setup and Test Mapnik iOS SDK v2.2.0

First set up a project directory to hold your work:

cd ~/projects
mkdir mapnik-ios-test
cd mapnik-ios-test

Next clone the mapbox-ios-example repo to get the MapBox iOS SDK and example code setup

git clone
cd mapbox-ios-example

Download and unpack the Mapnik iOS SDK

curl -f -O
tar xf mapnik-ios-v2.2.0.tar.bz2 # will give you a 'mapnik-ios' directory
# put the protoc compiler on your path so you can build mapnik-vector-tile
export PATH=`pwd`/mapnik-ios/bin:$PATH

Get the mapnik-vector-tile code and build it

git clone
cd mapnik-vector-tile
cd ../

Set up the MapBox SDK

git submodule update --init --recursive
# checkout `mapnik` branch of MapBox SDK
cd MapBox-iOS-SDK
git fetch -v
git checkout mapnik
cd ../

Now create an xcconfig file dynamically based on the Mapnik SDK build settings

# reference on options:
echo 'COMPRESS_PNG_FILES = NO' > mapnik-ios.xcconfig
echo 'GCC_VERSION =' >> mapnik-ios.xcconfig
echo 'CLANG_CXX_LANGUAGE_STANDARD = gnu++98' >> mapnik-ios.xcconfig
echo 'CLANG_CXX_LIBRARY = libstdc++' >> mapnik-ios.xcconfig
echo 'OTHER_CPLUSPLUSFLAGS = $(inherited) -I"$(SRCROOT)/mapnik-ios/include/" -I"$(SRCROOT)/mapnik-vector-tile/src/" '$(./mapnik-ios/bin/mapnik-config --defines) >> mapnik-ios.xcconfig
echo 'OTHER_LDFLAGS = $(inherited) -L"$(SRCROOT)/mapnik-ios/lib" -lmapnik -lprotobuf-lite '$(./mapnik-ios/bin/mapnik-config --dep-libs) >> mapnik-ios.xcconfig

Now open the sample project that came with the mapbox-io-example clone

open "MapBox Example.xcodeproj"

Add the mapnik-ios.xcconfig to your project: a good way to do this is drag/drop in into your MapBox Example> Supporting Files

Then edit the Project > Info > Based on Configuration File and set the Release and Debug configurations at the project level to use 'mapnik-ios.xcconfig'. NOTE: only set it at the project level, not the target. All targets should inherit from the project level xcconfig setting. If you are not seeing this happening try cleaning the project multiple times or closing and re-opening XCode (it tends to frustratingly and mysteriously cache things).

Now we are ready to test building the project. Hit Build and Run.

Next let's test actually including Mapnik C++ headers:

  1. Find some view controller code like MapBox Example/OfflineLayerViewController.m

  2. Either change the extension to .mm or set the Identity and Type > File Type to Objective C++ Source

  3. In your view controller code put #include <mapnik/map.hpp> near the top of the file and the following code inside the viewDidLoad:

     mapnik::Map m(256,256);
     NSLog(@"map dimensions: %d/%d", m.width(), m.height());
  1. Do a test build and make sure compile and linking is working.

  2. If it is working your Mapnik iOS SDK is working. If you hit missing headers or link errors then please create an issue at to report the problem

Note: a common problem is for the <mapnik/map.hpp> header to not be found. This is because the mapnik-ios.xcconfig is either not set up correctly or being read by your project correctly. Please repeat the setup steps again to make sure you did not miss anything.

Next steps: COMING SOON


This comment has been minimized.

Copy link

@ccarse ccarse commented Jul 22, 2013

Any idea when you'll release the next steps?? Thanks!


This comment has been minimized.

Copy link

@Whirlwind Whirlwind commented Aug 29, 2013

I am waiting ...


This comment has been minimized.

Copy link

@langyufei langyufei commented Aug 29, 2013

I been waiting for a while...


This comment has been minimized.

Copy link

@DanSalagean DanSalagean commented Oct 16, 2013

I am eagerly awaiting an update on this as well. I would like to know what's necessary in order to reproduce the iOS demo you gave at State of the Map: US a few months ago.

So far, I've installed protobuf, mapnik 2.2.0, TileMill 2, gdal, node, all the other required dependencies. I cannot yet figure out how to store the vector tiles for a city on my iPad mini and use Mapnik v2.2.0 to render it using the Mapbox iOS SDK.

I'm currently rendering maps on my iPad mini by using an in-house tile server. I can also do it using an SQLite or MBTiles db stored to disk. Right now, this takes up 3.2gb of the iPad's disk. I'd like to speed everything up as well as reduce the size of the cache by making use of the magical tech you displayed at SOTM.

Please consider updating this gist soon, as I'll continue to keep trying until I hit a brick wall, which will probably be very soon :)

That aside, sincerest thanks to MapBox for your great work, code and presentations. You folks continue to revolutionize the reach and impact of OSM data with your technology and open-source contributions. I'm very excited to see -- and be a part of -- this exciting landscape as it matures, improves, and gains even more widespread adoption.

  • Dan S.

This comment has been minimized.

Copy link

@pergustas pergustas commented Nov 15, 2013

Anybody built a Arm64 version for the A7-processor?


This comment has been minimized.

Copy link

@mohpor mohpor commented Feb 20, 2014

Is it possible to have OSM / GDAL / OGR libraries into the fat binary of mapnik for iOS?
better yet, is it possible to share the makefile or bash file to compile manik for iOS on mac osx? (I can see that you use scone for building Mapnik, is it possible to change the script for arch. armv7x?)
or is it possible to have other libs included in the project on demand.
I don't see libshape (ESRi Shape files) in the lib directory.


This comment has been minimized.

Copy link

@svelmuruganrvs svelmuruganrvs commented Dec 19, 2015

When i tried to execute make for mapnik-vector-tile by following comment's

cd mapnik-vector-tile


i am getting the Error as follow in OSX 10.10.5, Xcode 7.1.1
In file included from /Applications/
/Applications/ fatal error:
'unistd.h' file not found

include <unistd.h>


1 error generated.
make[1]: *** [Release/] Error 1
make: *** [libvtile] Error 2

does anyone know about it ??


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.