iOS
Generating an iOS XCode Project 2017
- Details
- Category: iOS
- Published: 22 February 2017
- Written by Thomas Hogarth
- Hits: 10700
This is an updated simplified guide to build OpenSceneGraph for iOS. The version tested against was osg 3.5.6
What you'll need
- OpenSceneGraph Source (Available from the downloads section)
- XCode 8.0 with iOS SDK 10.0 (Available from the OSX AppStore)
- CMake 3.6.1 (Available here http://www.cmake.org/cmake/resources/software.html)
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.