This repo contains the source code for Terraso’s mobile client modules.
Before contributing to the project, it's recommended that you set up your local git running the following command:
$ make setup-git-hooks
This will activate two git hooks to check JavaScript code style and commit message structure before each commit.
Set MAPBOX_DOWNLOADS_TOKEN
in your .env
to a valid Mapbox secret key.
$ brew install node watchman ruby openjdk@17
$ sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk
$ echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
$ source ~/.zshrc
$ gem install bundler
All users:
$ cd dev-client
Install NPM and Ruby packages:
$ npm install
$ bundle install
$ cd ios
$ bundle exec pod install
If you get this error:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
Then run this:
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Install Xcode from the App Store. Install the iOS SDK and Simulator.
Install Android Studio. Use the setup wizard to install the standard configuration, which will install the SDK.
Configure Android SDK environment variables:
cat << EOF > $HOME/.zprofile
export JAVA_HOME=`/usr/libexec/java_home`
export ANDROID_HOME="$HOME/Library/Android/sdk"
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator/
EOF
$ sudo apt install node watchman openjdk-17-jdk
Do not use the a
or i
subcommands in npm run start
, they don't work with our workflow.
The below commands implicitly call npm run start
when they are finished, so you shouldn't ordinarily
need to call it manually.
npm run android
to load the app on an emulator or connnected physical device.npm run android -- --variant release
to load a release build of the app onto an emulator or connected physical device.npm run ios
to load the app in the simulator.npm run ios -- --configuration release
to load a release build of the app in the simulator.npm run ios -- --device "Jane iPhone"
to load the app in on your device.keytool -genkey -v -keystore terraso-lpks-key.keystore -alias terraso-lpks -keyalg RSA -keysize 2048 -validity 10000
Add this to ~/.gradle/gradle.properties
. Use the password you created in “generate a keystore.”
cat << EOF >> ~/.gradle/gradle.properties
LPKS_UPLOAD_STORE_FILE=terraso-lpks-key.keystore
LPKS_UPLOAD_KEY_ALIAS=terraso-lpks
LPKS_UPLOAD_STORE_PASSWORD=XXXXX
LPKS_UPLOAD_KEY_PASSWORD=XXXXXX
EOF
mv terraso-lpks-key.keystore mobile-client/dev-client/android/app
From mobile-client/dev-client/android
:
Build the app bundle:
./gradlew bundleRelease
Sign the app bundle:
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore ~/terraso-lpks-key.keystore -signedjar app/build/outputs/bundle/release/terraso-landpks.aab app/build/outputs/bundle/release/app-release.aab terraso-lpks
Ensure you are using a verison of Java compatible with gradle. JDK 17 works with Gradle 8.3.
Once all of the dependencies are installed, you'll need to do the following to enable logins:
.env.sample
to .env
. Change GOOGLE_OAUTH_APP_CLIENT_ID
variable to match the value of your OAuth App client ID in Google Cloud Console.settings.py
value JWT_EXCHANGE_PROVIDERS
. You will need to set the environment variable GOOGLE_MOBILE_CLIENT_ID