mirror of
https://github.com/status-im/status-react.git
synced 2025-02-04 07:06:18 +00:00
42cab08553
After upgrading `react-native` to `0.72.5` we frequently started seeing the _red screen of death_ on both `Android` and `iOS` simulators right after the app was built and installed. This used to happen because our workflow required us to do the following : - `make run-clojure` - `make run-metro` - `make run-ios` OR `make run-android` The problem with this approach was after `metro` was started the `iOS`, `Android` build step would change the files that `metro` couldn't handle and hence metro would go out of sync. The quick fix back then was to restart `metro` terminal and to open the app again from the simulator. This was however not a good DX. This commit fixes that. We no longer rely on `react-native` cli to generate and deploy debug builds on simulators. We take control of the process via our own script. The new workflow introduced in this commit will first build the app, then install the app on the simulators and then start metro terminal. When `metro` is successfully running the script will then open the app. The new workflow now is : - `make run-clojure` - `make run-ios` OR `make run-android`
54 lines
1.3 KiB
Bash
Executable File
54 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
set -m # needed to access jobs
|
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
|
|
|
# We run Metro in background while calling adb.
|
|
cleanupMetro() {
|
|
pkill -f run-metro.sh
|
|
rm -f metro-server-logs.log
|
|
}
|
|
|
|
# Using function gives a neater jobspec name.
|
|
runMetro() {
|
|
nohup "${GIT_ROOT}/scripts/run-metro.sh" 2>&1 \
|
|
| tee metro-server-logs.log
|
|
}
|
|
|
|
waitForMetro() {
|
|
set +e # Allow grep command to fail in the loop.
|
|
TIMEOUT=5
|
|
echo "Waiting for Metro server..." >&2
|
|
while ! grep -q "Welcome to Metro" metro-server-logs.log; do
|
|
echo -n "." >&2
|
|
sleep 1
|
|
if ((TIMEOUT == 0)); then
|
|
echo -e "\nMetro server timed out, exiting" >&2
|
|
set -e # Restore errexit for rest of script.
|
|
return 1
|
|
fi
|
|
((TIMEOUT--))
|
|
done
|
|
set -e # Restore errexit for rest of script.
|
|
}
|
|
|
|
# Generate android debug build.
|
|
export ANDROID_ABI_INCLUDE=$("${GIT_ROOT}/scripts/adb_devices_abis.sh")
|
|
export BUILD_ENV=debug
|
|
export BUILD_TYPE=debug
|
|
"${GIT_ROOT}/scripts/build-android.sh"
|
|
|
|
# Install the APK on running emulator or android device.
|
|
adb install ./result/app-debug.apk
|
|
|
|
trap cleanupMetro EXIT ERR INT QUIT
|
|
runMetro &
|
|
waitForMetro
|
|
|
|
# Start the installed app.
|
|
adb shell monkey -p im.status.ethereum.debug 1
|
|
|
|
# bring metro job to foreground
|
|
fg 'runMetro'
|