Skip to content

Building for iOS

Johan Sköld edited this page Jul 15, 2016 · 1 revision

General build steps:

mkdir build-ios
cd build-ios
cmake -D CMAKE_TOOLCHAIN_FILE=../scripts/cmake/ios.cmake -G Xcode ..

Then open and build the sc.xcodeproj file in XCode.

If you just want a binary library file that you can just link with, you may instead just use makefiles:

mkdir build-ios
cd build-ios
cmake -D CMAKE_TOOLCHAIN_FILE=../scripts/cmake/ios.cmake ..
make

Simulator

To build for the iOS simulator rather than a real device, define the IOS_SIMULATOR variable on the cmake command line:

cmake -D CMAKE_TOOLCHAIN_FILE=../scripts/cmake/ios.cmake -D IOS_SIMULATOR=1 ..

Universal build

In order to make a universal build, you should define IOS_ARCHITECTURES to a semi-colon separate list of architectures you want to include. The default when not defined is armv7;armv7s;arm64 for an iOS device, or i386;x86_64 for the simulator.

For example, to exclude arm64:

cmake -D CMAKE_TOOLCHAIN_FILE=../scripts/cmake/ios.cmake -D IOS_ARCHITECTURES='armv7;armv7s' ..

Signing

In order to run the tests in the simulator, you simply have to change the target to sc_tests, build the project, and run it. This is not true if you want to run the tests on an actual device. To do this, you must sign the app first.

After generating and opening the project, click the sc project in the project navigator in the left pane. Select the sc_tests target from the target drop down (or if you have the targets list showing, click it in that list), and go to the Build Settings tab. Change the Code Sign Identity to the signature you use for running iOS apps. Now you should be able to build and run.