A cross platform demonstration of the execution of Rust code in React Native.
The application passes a string to the RN Native interface which then uses ring to create a sha256 hash of the input.
The hash is then displayed on the front-end of the app.
This app depends on an installation of Android Studio for Android and Xcode for iOS.
Additionally the Android deployment requires the SDK for Android API 21 and the Android NDK to be installed using the Android Studio SDK manager.
- Do NOT use brew/apt to install the Android SDK/NDK. Download the official version from the website.
- You may need to accept the Xcode license agreement in order to build:
sudo xcodebuild -license
Both Android and iOS require that the NPM dependencies for React Native be installed locally and the react-native-cli
globally.
$ npm install
$ npm -g install react-native-cli
You must install the necessary rust targets in order to cross-compile for different architectures.
# iOS
$ rustup target add i386-apple-ios
$ rustup target add armv7-apple-ios
$ rustup target add armv7s-apple-ios
$ rustup target add aarch64-apple-ios
$ rustup target add x86_64-apple-ios
# Android
$ rustup target add i686-linux-android
$ rustup target add arm-linux-androideabi
$ rustup target add armv7-linux-androideabi
$ rustup target add aarch64-linux-android
$ rustup target add x86_64-linux-android
(./) $ ./create-ndk-standalone.sh
(./) $ cd rust
(./rust) $ make install-android
(./rust) $ cd ..
(./) $ react-native run-android
(./) $ cd rust
(./rust) $ make ios
(./rust) $ cd ..
...?
(./) $ react-native run-ios
TODO the make ios
command results in the built iOS library being written to ./rust/target/universal/release/libmobile_app.a
. This needs to be used to create an iOS interface for RN.