/ Generating an iOS XCode Project 2017

OpenSceneGraph

iOS

Generating an iOS XCode Project 2017

This is an updated simplified guide to build OpenSceneGraph for iOS. The version tested against was osg 3.5.6

What you'll need

 

Setup project folder

Create a folder on your machine where you'll download the third party dependancies for OSG and the OSG source code we want to build. In this example we create

/Users/thomashogarth/osg-ios

Download the third party dependancies from the below link and extract into your project folder

hogbox.com/downloads/libs/3rdParty.zip

 

Get OSG Source

Clone the osg source into our project folder

cd /Users/thomashogarth/osg-ios
git clone https://github.com/openscenegraph/OpenSceneGraph.git osg 

 

Run CMake

Our project folder should now look like this

/osg-ios
/3rdParty
/osg

Now open a terminal window, cd to your osg folder and run the following command being sure to change the THIRD_PARTY export to point to your 3rdParty folder and change the IPHONE_SDKVER to the iOS sdk version you have installed.

export THIRDPARTY_PATH=/Users/thomashogarth/osg-ios/3rdParty
cmake ./ -G Xcode -DOSG_BUILD_PLATFORM_IPHONE:BOOL=ON \
-DIPHONE_SDKVER="10.2" \
-DIPHONE_VERSION_MIN="8.0" \
-DOPENGL_PROFILE:STRING=GLES2 \
-DBUILD_OSG_APPLICATIONS:BOOL=OFF \
-DBUILD_OSG_EXAMPLES:BOOL=ON \
-DOSG_WINDOWING_SYSTEM:STRING=IOS \
-DOSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX="imageio" \
-DDYNAMIC_OPENSCENEGRAPH:BOOL=OFF \
-DDYNAMIC_OPENTHREADS:BOOL=OFF \
-DCURL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/curl-ios-device/include" \
-DCURL_LIBRARY:PATH="$THIRDPARTY_PATH/curl-ios-device/lib/libcurl.a" \
-DFREETYPE_INCLUDE_DIR_freetype2:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include/freetype" \
-DFREETYPE_INCLUDE_DIR_ft2build:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include" \
-DFREETYPE_LIBRARY:PATH="$THIRDPARTY_PATH/freetype-ios-universal/lib/libFreeType_iphone_universal.a" \
-DTIFF_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/tiff-ios-device/include" \
-DTIFF_LIBRARY:PATH="$THIRDPARTY_PATH/tiff-ios-device/lib/libtiff.a" \
-DGDAL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/gdal-ios-device/include" \
-DGDAL_LIBRARY:PATH="$THIRDPARTY_PATH/gdal-ios-device/lib/libgdal.a"

Open the generated Xcode project, select the example_osgViewerIPhone target. In 'General' tab set a development team. In the 'Build Settings' tab search for 'Other Linker Flags', then for each target type (debug, release etc) that you want to use open the list of arguments and delete the 'OpenGL' line and the '-framework' line above it. This is because cmake has tried to add the desktop OpenGL library which we don't want.

Once this is done you should be able to build and deploy the example_osgViewerIPhone target on your device.