Alex Rivera | Logout

Incorporating GDAL/OGR into an iOS project - A quick guide

Asked 2012-09-28T16:29:45.360
11

Here is the problem: GDAL is a fantastic open source library designed to manage complex GIS data, both raster as well as vector. It is fully compiled for the Mac OS (courtesy of William Kyngesburye) and other platforms but not for iOS.

Browsing the net you can find bits and pieces of (relatively old) information on the topic of creating an iOS library, starting with the famous script from pseudogreen which was written over 3 years ago. There are also bits and pieces on stack-overflow such as GDAL / OGR on the iPhone which provide additional information.

This article is meant to cover all the steps I took which led me to a fully functional integration of GDAL/OGR in a simple iOS app using iOS6 and XCode 4.5.5

Edit
Report

1 Answer

20

Note

This response was written some time ago and mo longer works with Xcode 6 and up. Please check this link for a more current answer to this problem.

Introduction

Incorporating GDAL into your iOS app is a 5 steps process:

  1. Download the GDAL source code from the GDAL website
  2. Run the configure/build/install script given below
  3. Add the resulting static library into your iOS project along with the include files
  4. Link with additional libraries in your iOS project
  5. Start coding... the GDAL and OGR tutorials are good starting points

Downloading GDAL

GDAL is a C++ open source library which can be downloaded from the www.gdal.org web site. At the time of writing the latest version is 1.9.0. You should download the latest stable version if possible.

Run the script to compile GDAL for iOS and the simulator

In order to use GDAL in your iOS project you need to compile the source code as a static library (.a). With the latest iOS6-supported architecture you should create the static library for the following architectures:

  • i386 for the simulator
  • armv7 for iPhone 3GS to iPhone 4S
  • armv7s for iPhone 5

Base script to build for 1 architecture

The following script, which is adapted from pseudogreen's does the trick of compiling the source code for a single architecture.

Copy paste this code into a text editor and save it as file with .sh extension: for instance build_gdal_ios.sh.

To use it copy the script into the directory where you downloaded the gdal source code and run it as follows:

  • To build the library for the simulator:

answered 2012-09-28T16:29:45.360

Your Answer