Update howtobuild authored by Roland Alton's avatar Roland Alton
## How to build the app on Ubuntu 18.04
- Clone repository and select branch fairchat-master (or mergeWith1.n.n)
```bash
$ git clone git@git.fairkom.net:chat/fairchat.ReactNative.git
$ cd fairchat.ReactNative
$ git checkout fairchat-master
```
(or checkout the branch with latest merge from upstream Rocket.Chat-ReactNative)
- Install OpenJDK 8 (version 11 may have problems as some libraries are [deprecated](https://stackoverflow.com/questions/55735400/how-to-fix-java-lang-module-findexception-module-java-se-ee-not-found-error-w) like java.se.ee) and check if both java and javac are the same version 8
- Install Android Studio custom set-up with checkboxes on for:
> Android SDK
> Android SDK Platform
> Android Virtual Device
(see also https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment )
```bash
export ANDROID_HOME=~/Software/AndroidSDK
```
- Install dependencies from working dir and be sure to have a stable node version (10.13 or higher, not 8)
```bash
$ sudo apt install nodejs npm curl
$ sudo npm cache clean -f
$ sudo npm install -g n
$ sudo n stable
$ sudo npm install -g yarn
$ sudo npm install -g react-native-cli
$ sudo chown -R $USER:$(id -gn $USER) /home/ras/.config
$ yarn global add react-native-cli
$ yarn config set cache-folder /media/someGBstorage/yarn/cache/
$ yarn
- forward 8081 ports if device is connected via USB (or change dev settings in device to connect via same WIFI to port 8081 on pc)
```bash
$ adb reverse tcp:8081 tcp:8081
```
- Run Metro handler on port 8081 in separate terminal window in same working dir
```bash
$ npm start
```
- Build and run application
```bash
$ react-native run-ios
```
```bash
$ react-native run-android
```
- Changing branch or merging commits requires full rebuild (react-native should not require this ...)
```bash
$ git checkout newfeature
$ yarn
$ react-native run-android
```
- You may also need to rebuild the storybook, which is checked with pre-commit (or do a `git clean` to remove the commit syntax checking)
```bash
yarn add --dev jest
yarn global add jest
jest --updateSnapshot
```