# Building Scol for iOS ## Dependencies ### Prerequisites You will need *CMake 3.5*. In your home directory, create a file named `dev/NoCodeSign.xconfig`. Within this file, put the following line: `CODE_SIGNING_REQUIRED = NO` Then, put the following lines in your `.bash_profile` file in your home directory (create it if it doesn't exist): ``` export XCODE_XCCONFIG_FILE=/Users/bastien/dev/NoCodeSign.xconfig PATH="/Applications/CMake.app/Contents/bin":"$PATH" export PATH=$PATH ``` ### Get OpenCV Get the latest OpenCV release at https://github.com/Itseez/opencv. Extract the sources, preferably into `dependencies/OpenCV/sources`. Apply the patch for IOS : git apply --stat /Users/bastien/Documents/svn-scol/dependencies/OpenCV/patch/opencv_ios.patch git apply --check /Users/bastien/Documents/svn-scol/dependencies/OpenCV/patch/opencv_ios.patch git apply /Users/bastien/Documents/svn-scol/dependencies/OpenCV/patch/opencv_ios.patch ###git am --signoff < /Users/bastien/Documents/svn-scol/dependencies/OpenCV/patch/opencv_ios.patch ### Get Qt Get the latest version of Qt sources from http://download.qt.io/official_releases/qt/5.7/5.7.0/single/qt-everywhere-opensource-src-5.7.0.tar.gz The current version is 5.7, replace it if needed. Extract the sources into `dependencies/Qt/sources`. ### Building the dependencies Every dependency is built using CMake. From a command prompt, run `cmake-gui &` (we need to run it from a command prompt so that it takes every env variable into account). Select the `dependencies` folder as source folder, `dependencies/build/apple/IOS` as build folder. Hit `Configure`. Choose Xcode as generator, and specify the iOS toolchain file : `dependencies/CMake/toolchain/IOS.toolchain.cmake`. You can then generate the Xcode project right away. To build the generated project, cd to the build directory, and then run `PATH=/usr/bin:$PATH xcodebuild -configuration -target install`. The reason we override `PATH` is to prevent some tools that could be installed by 3rd party software (like Homebrew) to override the default system build tools, which could cause errors. The `install` target will install the built dependencies to `dependencies/sdk/apple/IOS` by default. Once this is done, you can proceed to re-configure the project in CMake to build the remaining dependencies, in the order specified at the top of the CMake output log: 1. libjpeg, FreeImage, zlib, ZZiplib, Aruco, Newton, libogg, libvorbis, FFmpeg (the step we just completed) 2. libzip, libPng, curl, cAudio, Assimp, ARToolKit 3. libharu, Ogre, Qt, OpenCV 4. SkyX, HydraX *Note:* Curl and FFmpeg are built using a custom script with a dummy CMake target. Once they've been built, you might need to uncheck `SCOLDEPS_BUILD_CURL` and `SCOLDEPS_BUILD_FFMPEG` to prevent CMake from re-building them at every run. When building OpenCV and Qt, you can set the path to their source tree if you did not unpack them in `dependencies/qt/sources` and `dependencies/OpenCV/sources`, by setting the CMake variables `QT_SOURCES_DIR` and `OPENCV_SOURCES_DIR`. ### Build OpenSSL - needed only if not using DarwinSSL included with iOS and OSX By default, the build process will use DarwinSSL instead of OpenSSL. If for some reason you want to use OpenSSL, you can do the following: In the OpenSSL folder (trunk/dependencies/OpenSSL), there is a script to download and build OpenSSL for both OSX and iOS. Open this scirpt in a text editor. At the top of the file, there are 4 variables that you can edit if needed. In particular, you should set OPENSSL_VERSION to the latest version of OpenSSL. Once this is done, you can run the script. It will create `include` and `lib` folders to install the resulting files.