summaryrefslogtreecommitdiff
path: root/docs/BUILD_IOS.adoc
blob: 573daf5040389bffab28feaaa3a7ecc7fa40088c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
= Building for iOS (and tvOS, watchOS)

NOTE: I am not an iOS developer, so this work is not fully tested.
It seems to work, but YMMV!

First, you will need to download a suitable toolchain file.

At the time of this writing (May 28, 2018), the toolchain file
located at https://github.com/leetal/ios-cmake is appears to work
reasonably well.

When building for iOS and similar targets, only static libraries may be built.
(This is good for avoiding dependency nightmares anyway.)

Using the above toolchain file, we can build for iOS using
the CMake standard CMAKE_TOOLCHAIN_FILE macro, and using
the IOS_PLATFORM macro to set the target.

We also need to disable tests and tools, since we can't build command line
executables for that environment.  These are controlled by setting
NNG_TESTS and NNG_TOOLS both to OFF.

You will also need to use the Xcode generator.

So, for example:

[source, sh]
----
% mkdir ios-build
% cd ios-build
% cmake -G Xcode \
	-DCMAKE_TOOLCHAIN_FILE=$GITROOT/ios-cmake/ios.toolchain.cmake \
	-DIOS_PLATFORM=OS \
	-DNNG_TESTS=OFF \
	-DNNG_TOOLS=OFF ..
----

Then you can build using Xcode, or simply use cmake to drive the build:

[source, sh]
----
% cmake --build .
----

Extra effort may be required to enable the use of mbedTLS (NNG does not
at the time of writing support Secure Transport.  See issue #497 for status.)