Building osgEarth (and OSG) for iOSΒΆ

When building osgEarth for iOS it is important to note that it requires two separate builds to build for both the simulator and devices. The instructions below are configured to build the libraries for use with devices. Building for use in the simulator is the same but requires pointing to the proper libraries when building.

The steps to buld for use on devices are as follows:

  1. Install CMake 2.8.8 or above
    Or install MacPorts and then sudo ports install cmake
  2. Install XCode 4.5.1
    Download from AppStore
  3. Get Dependencies
    Prebuilt dependencies courtesy of Thomas Hogarth can be downloaded here:
  4. Javascript Support
    Unlike osgEarth on the desktop which uses the V8 engine, osgEarth on iOS depends on the JavaScriptCore engine for scripting support.
    The JavaScriptCore code with projects for iOS can be found on GitHub here:
    As noted on that page, a prebuilt library can be found in the source tree of the Ejecta project
  5. Download OSG trunk

    mkdir osgearth-build
    cd ./osgearth-build
    svn checkout osg-ios
  6. Edit CMakeList.txt to point to your version of iOS SDK
    Check /Applications/
    Open CMakeList.txt and change line 236 to your SDK version: (SET (IPHONE_SDKVER "5.1" CACHE STRING "IOS SDK-Version")
    For the lib tiff plugin it is also currently necessary to copy line 587 and paste inside the else statement at line 593 (submited to osg trunk)
  7. Run CMake to generate OSG XCode Project
    Use below command line to generate static GLES2 build for iOS devices, change 3rdparty paths to reflect your 3rdparty path
    cd ./osg-ios
    -DCURL_INCLUDE_DIR:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/curl-ios-device/include" \
    -DCURL_LIBRARY:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/curl-ios-device/lib/libcurl.a" \
    -DFREETYPE_INCLUDE_DIR_freetype2:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/freetype-ios-universal/include/freetype" \
    -DFREETYPE_INCLUDE_DIR_ft2build:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/freetype-ios-universal/include" \
    -DFREETYPE_LIBRARY:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/freetype-ios-universal/lib/libFreeType_iphone_universal.a" \
    -DTIFF_INCLUDE_DIR:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/tiff-ios-device/include" \
    -DTIFF_LIBRARY:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/tiff-ios-device/lib/libtiff.a" \
    -DGDAL_INCLUDE_DIR:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/gdal-ios-device/include" \
    -DGDAL_LIBRARY:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/gdal-ios-device/lib/libgdal.a" \
  8. Open XCode project generated and run BUILD_ALL target

  9. Download osgEarth trunk

    cd ../
    git clone git:// osgearth-ios
  10. Edit iOS SDK version in ``./osgearth-ios/CMakeList.txt`` (see item 5)

  11. Run CMake to generate osgEarth Xcode project
    Use below command line to generate static bulild for iOS device, change 3rdparty paths to reflect your 3rdparty path
    -DOSG_DIR:PATH="/Users/hogbox/Documents/osgearth-build/osg-ios" \
    -DCURL_INCLUDE_DIR:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/curl-ios-device/include" \
    -DCURL_LIBRARY:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/curl-ios-device/lib/libcurl.a" \
    -DGDAL_INCLUDE_DIR:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/gdal-ios-device/include" \
    -DGDAL_LIBRARY:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/gdal-ios-device/lib/libgdal.a" \
    -DGEOS_INCLUDE_DIR:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/geos-ios-device/include/source/headers" \
    -DGEOS_LIBRARY:PATH="/Users/hogbox/Documents/osgearth-build/3rdParty/geos-ios-device/lib/libGEOS_3.2.a" \
  12. Open generated Xcode project and build
    For now do not build application targets as they will generate errors (CMake can not currently generate valid application targets for iOS)
    Select OSGEARTH project in navigator view (top of tree on left)
    Select Add Target
    Select Aggregate Target in the Other section, name it lib-build (or whatever)
    Select new target and select Build Phases, Target Dependencies, +
    Select all the libs and plugins
    Select the new target as the current build target (combo box to right of the play/run button)
  13. Open and build example project

    Edit Header Search Paths in build settings point to your osg and osgearth folders
    Edit Library Search Paths in build settings point to your osg and osgearth folders
    Link to Accelerate.framework (fix sent)
    Link to MobileCoreServices.framework (fix sent)
    remove armv7s build if you are using freetypes