CoopCycle
Prerequisites
-
Install Node, Java Development Kit, Watchman & React Native CLI as described here.
-
You can install
react-native-cliwith following command:npm install –g react-native-cli -
Or you can use
npxwhich ships with Node.js instead of installing React Native CLI.With
npx react-native <command>, the current stable version of the CLI will be downloaded and executed at the time the command is run.
-
-
Install dependencies to compile node-canvas depending on your OS.
Setup - Firebase
Create a Firebase account.
Android
Follow the Firebase instructions to download and copy google-services.json to the android/app folder.
iOS
Follow the Firebase instructions to download and copy GoogleService-Info.plist to the ios/ folder.
Setup - All Platforms
Enable Corepack
$ corepack enable
Install dependencies with Yarn.
$ yarn install
Populate your local .env file:
$ cp .env.dist .env
Setup - Linux
-
To launch an Android emulator on Linux, you will need to enable acceleration.
-
You can run the app on your Android device following these instructions.
- You can display and control your Android device connected via USB with scrcpy.
Setup - Android
Get a Google Maps API Key
A Google Maps API Key is needed at compilation time for Android (see AndroidManifest.xml).
-
To get an API key follow the instructions Get API key
-
Make sure that you have
Maps SDK for AndroidAPI enabled in your Google Cloud Platform Console -
Add your API key to
.env
GOOGLE_MAPS_BROWSER_KEY=YOUR_API_KEY
GOOGLE_MAPS_ANDROID_KEY=YOUR_API_KEY
Those keys won't work for address autocomplete if you don't have billing enabled in Google Cloud. Before enabling billing in your project, read and check the the terms and conditions for the free trial.
Setup - iOS
iOS development requires macOS and CocoaPods.
bundle install
Install the dependencies:
cd ios && USE_FRAMEWORKS=static NO_FLIPPER=1 bundle exec pod install
Or using pod-install:
cd ios && USE_FRAMEWORKS=static NO_FLIPPER=1 npx pod-install
Running App
Start the bundler
make start
Run the Android app
make android
Run the iOS app
On any simulator:
make ios
With a picker to choose a specific simulator:
yarn ios --list-devices
On a connected physical device:
yarn ios --device
Testing
make test
Detox (end-to-end testing):
Setup: https://wix.github.io/Detox/docs/introduction/environment-setup
To run end-to-end tests locally make sure that:
- Set
APP_ENVtotest(already done when running fromMakefiletargets). - Set
COOPCYCLE_WEB_REPO_PATHin.envonly if your path tocoopcycle-webproject is other than:../coopcycle-web(used to run e2e tests against local web instance).
Build the app:
Android:
make e2e-build-android
iOS:
make e2e-build-ios
Run tests:
Android:
make e2e-android
iOS:
make e2e-ios
Run a single test, set the TESTFILE env var when running make e2e-android-only or make e2e-ios-only:
make e2e-android-only TESTFILE=courier/success__task__complete.spec.js
(note that it omits the e2e/ part of the path)
Run a single test in debug mode:
detox test -c ios.sim.debug --inspect-brk e2e/foodtech/first_launch.spec.js
Make sure that you have emulators set up as specified in .detoxrc.js > devices
or use --device-name parameter while running tests. For example:
detox test -c android.emu.debug --device-name="Pixel_8_API_34" e2e/foodtech/first_launch.spec.js
Troubleshooting
« Have you tried turning it off and on again? »
watchman watch-del-all
rm -rf $TMPDIR/react-*
rm -rf $TMPDIR/metro-*
rm -rf ~/.rncache
make start-fresh