These instructions are based on the README from the upstream Credible.
Install with:
brew install openjdk@11
and then add Java to your path by running the suggestion from:
brew info openjdk@11 | grep "export PATH"
Create ~/spruceid directory and clone didkit, ssi, trustchain and trustchain-mobile:
mkdir ~/spruceid && cd ~/spruceid
git clone -b dev https://github.com/alan-turing-institute/didkit.git
git clone -b dev --recursive https://github.com/alan-turing-institute/ssi.git
git clone https://github.com/alan-turing-institute/trustchain.git
git clone https://github.com/alan-turing-institute/trustchain-mobile.gitThe beta channel is essential for Mac ARM as the deprecated dev channel fails for targets:
git clone https://github.com/flutter/flutter.git -b beta $HOME/flutter
git -C $HOME/flutter checkout 3.7.0-1.5.pre
echo 'export PATH=$HOME/flutter/bin:"$PATH"' >> $HOME/.zshrc
source ~/.zshrc
# Check installation
flutter doctor -vNote: There is currently a dependency issue for flutter version 3.8 (latest version) so a current workaround is to checkout an earlier release (3.7.0-1.5.pre). This earlier release also comes with an older version of Dart, namely 2.19.0, which (unlike versions >=3.0.0) is compatible with DIDKIT.
-
If flutter is not able to find java, you can try:
cd /Applications/Android\ Studio.app/Contents ln -s jbr jre
Note: in case the
lnfails, you may need to grant Full Disk Access to Terminal (Settings > Privacy & Security > Full Disk Access > Drag in Terminal app + Activate toggle). -
If installing Xcode command line tools with
xcode-select --installdoes not work (already installed), then try installing Xcode from the App Store -
If installing CocoaPods from the suggested instructions does not work, then try with:
brew install cocoapods.
Download and install Android Studio.
Then go to Android Studio > Preferences > search for "SDK"
- SDK Platforms: Tick Android API 33
- SDK Tools:
- Android SDK Build-Tools
- NDK (side by side)
- Android SDK Command-line Tools (latest)
- Android Emulator
- Android SDK Platform-Tools
Add the following to your .zshrc replacing any y.z with specific versions:
# Add the brew installed openjdk@11
# For intel
# export JAVA_HOME=/usr/local/Cellar/openjdk@11/11.y.z/libexec/openjdk.jdk/Contents/Home
# For ARM
export JAVA_HOME=/opt/local/Cellar/openjdk@11/11.y.z/libexec/openjdk.jdk/Contents/Home
# SDK root
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
# Note difference from `install_dependencies_script.sh` with 'latest' instead of `tools`
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:"$PATH"
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/lib:"$PATH"
export PATH=$ANDROID_SDK_ROOT/tools:"$PATH"
export PATH=$JAVA_HOME/bin:"$PATH"
# The SDK is from Android studio install: set version as
export ANDROID_TOOLS=$ANDROID_SDK_ROOT/build-tools/33.y.z
# NDK: choose location of NDK (side by side) installed with Android studio
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/25.y.z
With the above in ~/.zshrc, run:
$ . ~/.zshrc
to set the env variables.
This is a required dependency for building the targets in step 7.
brew install llvm
export TARGET_CC=$(which clang)You may also need to add the llvm bin directory to your path. Run the following to see the instructions for this:
brew info llvm | grep "export PATH"cargo ndk provides the simplest method to build for Android targets. This is installed with:
cargo install cargo-ndk
Check the version installed is at least cargo-ndk 3.3.0 by running:
cargo ndk --version
This step provides the builds that provide the DIDKit FFI functionality.
A Rust installation (at least 1.68.0) is needed for this step. If necessary, follow the official instructions including adding ~/.cargo/bin to your path.
After installing rust you'll need to restart your shell, in which case you'll also need to re-export TARGET_CC from step 6.
Then continue with the actual build from the current repo root location:
cd ../didkit
make -C lib install-rustup-android
make -C lib ../target/test/java.stamp
cargo ndk -t armeabi-v7a -t arm64-v8a -t x86_64 -t x86 -o target/ build --lib --release
make -C lib ../target/test/flutter.stamp
cargo buildIn order to build and run the Trustchain FFI libraries, make sure the trustchain repository is cloned alongside the trustchain-mobile and didkit repositories (as was done in Step 2). Then, after moving to the trustchain repository , run:
cd ../trustchain
cargo ndk \
-t armeabi-v7a \
-t arm64-v8a \
-t x86_64 \
-t x86 \
-o ../trustchain-mobile/android/app/src/main/jniLibs build --lib
You can now test the FFI libraries by starting a trustchain-http server and running the tests in test/app/trustchain_ffi_tests.dart
- Open Android Studio
- Open devices (
Virtual Device Managerin theMore Actionsdropdown) - Make a new one with SDK 33 and latest Pixel Pro 6
- Press the play button to start it
- From the
trustchain-mobilerepository, install package dependencies with:
flutter pub get- And then with an android emulator running from the
trustchain-mobilerepository:
flutter run This runs the code from the branch you have checked out. The mobile app should now start on the emulator.
Note: If you get errors during this step, try to build and run the project in VS Code via the instructions in the next section.
- Open the repo in VS code
- Update
flutter-config.jsonwith your default values, for example:{ "trustchainEndpoint": "http://trustchain.uksouth.cloudapp.azure.com:8081", "rootEventTime": "1666971942" } - Install required dart and flutter extensions
- Click on the bottom right to choose the the installed android emulator
- Press
fn-F5to run from inside VS code and have the app hot reload upon save
- Changes to the localizations (language specific text references), can be written in:
with
lib/l10n/app_en.arb lib/l10n/app_fr.arb etc$ flutter gen-l10ncalled from the command line