1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-15 04:32:21 +00:00
ton/example/android
neodiX42 89700cb2aa
CI: fix macOS and tonlib Android GitHub actions in testnet (#786)
* fix macOS github actions

* fix android tonlib GH action;

* fixing wasm GH action

* strip binaries

* fix randomly failing ubuntu and wasm GH actions

* fix randomly failing ubuntu and wasm GH actions

* revert some changes
2023-10-30 11:52:00 +03:00
..
src/drinkless/org/ton updated smartcontracts 2019-10-23 17:43:50 +04:00
test emergency update 2020-03-24 03:32:16 +04:00
third_party TVM Upgrade (#686) 2023-05-24 21:14:13 +03:00
AddIntDef.php initial commit 2019-09-07 14:33:36 +04:00
build-all.sh TVM Upgrade (#686) 2023-05-24 21:14:13 +03:00
build.sh CI: fix macOS and tonlib Android GitHub actions in testnet (#786) 2023-10-30 11:52:00 +03:00
CMakeLists.txt TVM Upgrade (#686) 2023-05-24 21:14:13 +03:00
export.sh Add cross-platform Linux and macOS binaries (statically compiled with NixPkgs) + wasm artifacts (#621) 2023-02-27 12:32:41 +03:00
native-lib.cpp bugfixes 2020-04-10 23:06:01 +04:00
README.md TVM Upgrade (#686) 2023-05-24 21:14:13 +03:00
test.sh initial commit 2019-09-07 14:33:36 +04:00

Generation of Tonlib libraries for Android OS

Tl;dr Download the latest version of Tonlib libraries for Android from TON release page or check the artifacts from Android JNI GitHub action.

Compile Tonlib for Android manually

Prerequisite: installed Java and set environment variable JAVA_HOME.

git clone --recursive https://github.com/ton-blockchain/ton.git
cd ton
wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip android-ndk-r25b-linux.zip
export JAVA_AWT_LIBRARY=NotNeeded
export JAVA_JVM_LIBRARY=NotNeeded
export JAVA_INCLUDE_PATH=${JAVA_HOME}/include
export JAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include
export JAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux

export ANDROID_NDK_ROOT=$(pwd)/android-ndk-r25b
export OPENSSL_DIR=$(pwd)/example/android/third_party/crypto
export SECP256K1_INCLUDE_DIR=$(pwd)/example/android/third_party/secp256k1/include
export SECP256K1_LIBRARY=$(pwd)/example/android/third_party/secp256k1/.libs/libsecp256k1.a
export SODIUM_INCLUDE_DIR=$(pwd)/example/android/third_party/libsodium/libsodium-android-westmere/include
export SODIUM_LIBRARY=$(pwd)/example/android/third_party/libsodium/libsodium-android-westmere/lib/libsodium.a

rm -rf example/android/src/drinkless/org/ton/TonApi.java
cd example/android/
cmake -GNinja -DTON_ONLY_TONLIB=ON . 
ninja prepare_cross_compiling
rm CMakeCache.txt
./build-all.sh

Generation of Tonlib libraries for iOS in Xcode

  1. Clone repository https://github.com/labraburn/tonlib-xcframework
  2. Open repository directory in Terminal
  3. Run command:
swift run builder --output ./build --clean
  1. Run command:
echo ./build/TON.xcframework/* | xargs -n 1 cp -R ./Resources/Headers
  1. Import OpenSSL.xcframework and TON.xcframework in XCode in section "Frameworks, Libraries, and Embedded Content"
  2. Now you can start using Tonlib client by importing it in C or Objective-C source files:
#import <tonlib/tonlib_client_json.h>

Generation of Tonlib libraries for Desktop applications

You can use Tonlib compiled in an ordinary way for desktop applications. If you use Java you can load the library using JNA.

The latest Tonlib library can be found among other TON artifacts either on TON release page or inside the appropriate GitHub action.