2018-02-14 11:19:12 +01:00
|
|
|
# Build for iOS
|
|
|
|
|
2018-02-14 22:41:26 +01:00
|
|
|
Below are instructions for building TDLib for iOS, watchOS, tvOS, and also macOS.
|
2018-02-14 11:29:54 +01:00
|
|
|
|
2018-02-14 22:41:26 +01:00
|
|
|
If you need only a macOS build, take a look at our build instructions for [macOS](https://github.com/tdlib/td#macos).
|
2018-02-14 11:29:54 +01:00
|
|
|
|
2018-02-14 22:41:26 +01:00
|
|
|
For example of usage take a look at our [Swift example](https://github.com/tdlib/td/tree/master/example/swift).
|
2018-02-14 11:19:12 +01:00
|
|
|
|
2018-02-14 22:41:26 +01:00
|
|
|
To compile `TDLib` you will need to:
|
2018-05-15 14:29:43 +02:00
|
|
|
* Install the latest Xcode command line tools, for example, via `xcode-select --install`.
|
2018-02-14 22:41:26 +01:00
|
|
|
* Install other build dependencies, for example, using [Homebrew](https://brew.sh):
|
2018-02-14 11:19:12 +01:00
|
|
|
```
|
2018-02-14 22:41:26 +01:00
|
|
|
brew install gperf cmake
|
|
|
|
```
|
|
|
|
* If you don't want to build `TDLib` for macOS, you can pregenerate required source code files using CMake prepare_cross_compiling target:
|
|
|
|
```
|
|
|
|
cd <path to TDLib sources>
|
|
|
|
mkdir native-build
|
|
|
|
cd native-build
|
|
|
|
cmake ..
|
|
|
|
cmake --build . --target prepare_cross_compiling
|
|
|
|
```
|
|
|
|
* Build OpenSSL for iOS, watchOS, tvOS and macOS:
|
|
|
|
```
|
|
|
|
cd <path to TDLib sources>/example/ios
|
2018-02-14 11:19:12 +01:00
|
|
|
./build-openssl.sh
|
|
|
|
```
|
2018-02-14 22:41:26 +01:00
|
|
|
Here we use scripts from [Python Apple support](https://github.com/pybee/Python-Apple-support), but any other OpenSSL builds should work too.
|
|
|
|
Built libraries should be stored in `third_party/openssl/<platform>`, because the next script will rely on this location.
|
|
|
|
* Build TDLib for iOS, watchOS, tvOS and macOS:
|
2018-02-14 11:19:12 +01:00
|
|
|
```
|
2018-02-14 22:41:26 +01:00
|
|
|
cd <path to TDLib sources>/example/ios
|
2018-02-14 11:19:12 +01:00
|
|
|
./build.sh
|
|
|
|
```
|
2018-02-14 22:41:26 +01:00
|
|
|
This may take a while, because TDLib will be built about 10 times.
|
2018-06-01 15:00:04 +02:00
|
|
|
Resulting library for iOS will work on any architecture (armv7, armv7s, arm64) and even on a simulator.
|
2018-02-14 22:41:26 +01:00
|
|
|
We use [CMake/iOS.cmake](https://github.com/tdlib/td/blob/master/CMake/iOS.cmake) toolchain, other toolchains may work too.
|
2018-02-14 11:19:12 +01:00
|
|
|
|
2018-02-14 22:41:26 +01:00
|
|
|
Built libraries will be store in `tdjson` directory.
|
2018-03-02 01:34:02 +01:00
|
|
|
|
|
|
|
Documentation for all available classes and methods can be found at https://core.telegram.org/tdlib/docs.
|