Update iOS example README.md.
GitOrigin-RevId: df6d7bd81c1d1fdb915cb4bdc6edc80d93bcfed0
This commit is contained in:
parent
1424b2037e
commit
1d28119f4a
@ -60,7 +60,8 @@ cmake --build .
|
|||||||
<a name="installing-dependencies"></a>
|
<a name="installing-dependencies"></a>
|
||||||
### Installing dependencies
|
### Installing dependencies
|
||||||
|
|
||||||
#### OS X
|
<a name="macos"></a>
|
||||||
|
#### macOS
|
||||||
* Install the latest Xcode command line tools.
|
* Install the latest Xcode command line tools.
|
||||||
* Install other dependencies, for example, using [Homebrew](https://brew.sh):
|
* Install other dependencies, for example, using [Homebrew](https://brew.sh):
|
||||||
```
|
```
|
||||||
@ -71,6 +72,7 @@ brew install gperf cmake openssl
|
|||||||
cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ ..
|
cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ ..
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<a name="windows"></a>
|
||||||
#### Windows
|
#### Windows
|
||||||
* Download and install [gperf](https://sourceforge.net/projects/gnuwin32/files/gperf/3.0.1/). Add the path to gperf to the PATH environment variable.
|
* Download and install [gperf](https://sourceforge.net/projects/gnuwin32/files/gperf/3.0.1/). Add the path to gperf to the PATH environment variable.
|
||||||
* Install [vcpkg](https://github.com/Microsoft/vcpkg#quick-start).
|
* Install [vcpkg](https://github.com/Microsoft/vcpkg#quick-start).
|
||||||
@ -83,6 +85,7 @@ C:\src\vcpkg> .\vcpkg install openssl zlib
|
|||||||
cmake -DCMAKE_TOOLCHAIN_FILE=C:\src\vcpkg\scripts\buildsystems\vcpkg.cmake ..
|
cmake -DCMAKE_TOOLCHAIN_FILE=C:\src\vcpkg\scripts\buildsystems\vcpkg.cmake ..
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<a name="linux"></a>
|
||||||
#### Linux
|
#### Linux
|
||||||
* Install all dependencies using your package manager.
|
* Install all dependencies using your package manager.
|
||||||
|
|
||||||
|
@ -1,29 +1,39 @@
|
|||||||
# Build for iOS
|
# Build for iOS
|
||||||
|
|
||||||
Bellow are instructions for building TdLib for iOS, watchOS and also macOS.
|
Below are instructions for building TDLib for iOS, watchOS, tvOS, and also macOS.
|
||||||
|
|
||||||
If you need just macOS build take a look [here](https://github.com/tdlib/td#os-x).
|
If you need only a macOS build, take a look at our build instructions for [macOS](https://github.com/tdlib/td#macos).
|
||||||
|
|
||||||
For example of usage take a look [here](https://github.com/tdlib/td/tree/master/example/swift).
|
For example of usage take a look at our [Swift example](https://github.com/tdlib/td/tree/master/example/swift).
|
||||||
|
|
||||||
## Build OpenSSL
|
To compile `TDLib` you will need to:
|
||||||
First, you should build OpenSSL library for ios
|
* Install the latest Xcode command line tools.
|
||||||
|
* Install other build dependencies, for example, using [Homebrew](https://brew.sh):
|
||||||
```
|
```
|
||||||
|
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
|
||||||
./build-openssl.sh
|
./build-openssl.sh
|
||||||
```
|
```
|
||||||
In this example we are using scripts from [Python Apple support](https://github.com/pybee/Python-Apple-support), but any other OpenSSL builds should work too.
|
Here we use scripts from [Python Apple support](https://github.com/pybee/Python-Apple-support), but any other OpenSSL builds should work too.
|
||||||
Libraries will be stored in `third_party/openssl/<platfrom>`. The next script will rely on this location.
|
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:
|
||||||
## Build TdLib
|
|
||||||
Run:
|
|
||||||
```
|
```
|
||||||
|
cd <path to TDLib sources>/example/ios
|
||||||
./build.sh
|
./build.sh
|
||||||
```
|
```
|
||||||
This may take a while, because TdLib will be build about 8 times.
|
This may take a while, because TDLib will be built about 10 times.
|
||||||
As an upside resulting library for iOS will work on any architecture (arv7, armv7s, arm64) and even on a simulator.
|
Resulting library for iOS will work on any architecture (arv7, armv7s, arm64) and even on a simulator.
|
||||||
We use [CMake/iOS.cmake](https://github.com/tdlib/td/blob/master/CMake/iOS.cmake) toolchain, other toolchains
|
We use [CMake/iOS.cmake](https://github.com/tdlib/td/blob/master/CMake/iOS.cmake) toolchain, other toolchains may work too.
|
||||||
may work too.
|
|
||||||
|
|
||||||
Libraries will be store in `tdjson` directory.
|
|
||||||
|
|
||||||
|
|
||||||
|
Built libraries will be store in `tdjson` directory.
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
git clone https://github.com/pybee/Python-Apple-support
|
git clone https://github.com/pybee/Python-Apple-support
|
||||||
cd Python-Apple-support
|
cd Python-Apple-support
|
||||||
git checkout 2.7
|
git checkout 2.7
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
#TODO: change openssl version
|
#TODO: change openssl version
|
||||||
platforms="macOS iOS watchOS tvOS"
|
platforms="macOS iOS watchOS tvOS"
|
||||||
#platforms="macOS"
|
|
||||||
for platform in $platforms;
|
for platform in $platforms;
|
||||||
do
|
do
|
||||||
echo $platform
|
echo $platform
|
||||||
cd Python-Apple-support
|
cd Python-Apple-support
|
||||||
#NB: -j will fail
|
#NB: -j will fail
|
||||||
make OpenSSL-$platform
|
make OpenSSL-$platform
|
||||||
cd ..
|
cd ..
|
||||||
rm -rf third_party/openssl/$platform
|
rm -rf third_party/openssl/$platform
|
||||||
mkdir -p third_party/openssl/$platform/lib
|
mkdir -p third_party/openssl/$platform/lib
|
||||||
cp ./Python-Apple-support/build/$platform/libcrypto.a third_party/openssl/$platform/lib/
|
cp ./Python-Apple-support/build/$platform/libcrypto.a third_party/openssl/$platform/lib/
|
||||||
cp ./Python-Apple-support/build/$platform/libssl.a third_party/openssl/$platform/lib/
|
cp ./Python-Apple-support/build/$platform/libssl.a third_party/openssl/$platform/lib/
|
||||||
cp -r ./Python-Apple-support/build/$platform/Support/OpenSSL/Headers/ third_party/openssl/$platform/include
|
cp -r ./Python-Apple-support/build/$platform/Support/OpenSSL/Headers/ third_party/openssl/$platform/include
|
||||||
done
|
done
|
||||||
|
@ -10,12 +10,14 @@ for platform in $platforms;
|
|||||||
do
|
do
|
||||||
echo "Platform = ${platform} Simulator = ${simulator}"
|
echo "Platform = ${platform} Simulator = ${simulator}"
|
||||||
openssl_path=$(realpath ../third_party/openssl/${platform})
|
openssl_path=$(realpath ../third_party/openssl/${platform})
|
||||||
echo $openssl_path
|
echo "OpenSSL path = ${openssl_path}"
|
||||||
|
openssl_crypto_library="${openssl_path}/lib/libcrypto.a"
|
||||||
|
openssl_ssl_library="${openssl_path}/lib/libssl.a"
|
||||||
options="$options -DOPENSSL_FOUND=1"
|
options="$options -DOPENSSL_FOUND=1"
|
||||||
options="$options -DOPENSSL_CRYPTO_LIBRARY=${openssl_path}/lib/libcrypto.a"
|
options="$options -DOPENSSL_CRYPTO_LIBRARY=${openssl_crypto_library}"
|
||||||
#options="$options -DOPENSSL_SSL_LIBRARY=${openssl_path}/lib/libssl.a"
|
#options="$options -DOPENSSL_SSL_LIBRARY=${openssl_ssl_library}"
|
||||||
options="$options -DOPENSSL_INCLUDE_DIR=${openssl_path}/include"
|
options="$options -DOPENSSL_INCLUDE_DIR=${openssl_path}/include"
|
||||||
options="$options -DOPENSSL_LIBRARIES=${openssl_path}/lib/libcrypto.a;${openssl_path}/lib/libssl.a"
|
options="$options -DOPENSSL_LIBRARIES=${openssl_crypto_library};${openssl_ssl_library}"
|
||||||
options="$options -DCMAKE_BUILD_TYPE=Release"
|
options="$options -DCMAKE_BUILD_TYPE=Release"
|
||||||
if [[ $platform = "macOS" ]]; then
|
if [[ $platform = "macOS" ]]; then
|
||||||
build="build-${platform}"
|
build="build-${platform}"
|
||||||
@ -38,13 +40,13 @@ do
|
|||||||
install="install-${platform}"
|
install="install-${platform}"
|
||||||
if [[ $simulator = "1" ]]; then
|
if [[ $simulator = "1" ]]; then
|
||||||
build="${build}-simulator"
|
build="${build}-simulator"
|
||||||
install="${install}-simulator"
|
install="${install}-simulator"
|
||||||
ios_platform="SIMULATOR"
|
ios_platform="SIMULATOR"
|
||||||
else
|
else
|
||||||
ios_platform="OS"
|
ios_platform="OS"
|
||||||
fi
|
fi
|
||||||
if [[ $platform = "watchOS" ]]; then
|
if [[ $platform = "watchOS" ]]; then
|
||||||
ios_platform="WATCH${ios_platform}"
|
ios_platform="WATCH${ios_platform}"
|
||||||
fi
|
fi
|
||||||
if [[ $platform = "tvOS" ]]; then
|
if [[ $platform = "tvOS" ]]; then
|
||||||
ios_platform="TV${ios_platform}"
|
ios_platform="TV${ios_platform}"
|
||||||
@ -54,9 +56,7 @@ do
|
|||||||
mkdir -p $build
|
mkdir -p $build
|
||||||
mkdir -p $install
|
mkdir -p $install
|
||||||
cd $build
|
cd $build
|
||||||
echo "A"
|
|
||||||
cmake $td_path $options -DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake -DCMAKE_INSTALL_PREFIX=../${install}
|
cmake $td_path $options -DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake -DCMAKE_INSTALL_PREFIX=../${install}
|
||||||
echo "B"
|
|
||||||
make -j3 install || exit
|
make -j3 install || exit
|
||||||
cd ..
|
cd ..
|
||||||
done
|
done
|
||||||
@ -65,10 +65,10 @@ do
|
|||||||
mkdir -p $platform
|
mkdir -p $platform
|
||||||
lipo -create $lib $lib_simulator -o $platform/libtdjson.dylib
|
lipo -create $lib $lib_simulator -o $platform/libtdjson.dylib
|
||||||
install_name_tool -id @rpath/libtdjson.dylib $platform/libtdjson.dylib
|
install_name_tool -id @rpath/libtdjson.dylib $platform/libtdjson.dylib
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p ../tdjson/$platform/include
|
mkdir -p ../tdjson/$platform/include
|
||||||
rsync --recursive ${install}/include/ ../tdjson/${platform}/include/
|
rsync --recursive ${install}/include/ ../tdjson/${platform}/include/
|
||||||
mkdir -p ../tdjson/$platform/lib
|
mkdir -p ../tdjson/$platform/lib
|
||||||
cp $platform/libtdjson.dylib ../tdjson/$platform/lib/
|
cp $platform/libtdjson.dylib ../tdjson/$platform/lib/
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user