Setting up Travis for React Native

Andon Sikavica
May 12th, 2019 · 1 min read

Prerequisite is to have the build and deploy process already running and set-up via fastlane.

Parallel Build Jobs

Has to be done because:

  • You probably want to speed up the process
  • The Mac Environment on Travis can’t build Android due to a Java version it bundles

Mac Environment

Travis has macOS environment where additional tools need to be installed: yarn, react-native-cli, watchman, fastlane:

1- name: "iOS App Build and Deploy to iTunesConnect"
2 language: objective-c
3 os: osx
4 osx_image: xcode10.2
5 node_js:
6 - "8"
7 before_install:
8 - brew update
9 - brew install watchman
10 - travis_retry npm install -g yarn
11 - travis_retry npm install -g react-native-cli
12 - gem install fastlane --version 2.112.0 --no-document --quiet

Android Environment

Travis has a Linux environment, with an additional support for Android.

1- name: "Android App Build and Deploy to Google Play"
2 language: android
3 components:
4 - platform-tools
5 - tools
6 - extra-android-m2repository
7 - extra-google-google_play_services
8 - extra-google-m2repository
9 - add-on
10 - extra
11 licenses:
12 - android-sdk-preview-license-.+
13 - android-sdk-license-.+
14 - google-gdk-license-.+
15 before_install:
16 - nvm install 8
17 - travis_retry npm install -g yarn
18 - travis_retry npm install -g react-native-cli
19 - gem install fastlane --version 2.112.0 --no-document --quiet
20 - touch $HOME/.android/repositories.cfg
21 - yes | sdkmanager "platforms;android-27"
22 - yes | sdkmanager "build-tools;27.0.3"
23 - sudo apt-get install automake autoconf python-dev build-essential
24 - git clone https://github.com/facebook/watchman.git
25 - cd watchman
26 - git checkout v4.9.0
27 - ./autogen.sh
28 - ./configure
29 - make
30 - sudo make install
31 - cd ..
32 - echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Advanced Examples Reference

More articles from Andon Sikavica

React Native Project Setup for large projects

React Native does a lot with its project initialization using the following command: It creates a basic setup for the iOS and Android…

January 18th, 2016 · 2 min read

On Listening

...via few tweets

October 6th, 2020 · min read
© 2016–2020 Andon Sikavica
Link to $https://twitter.com/andonsikavicaLink to $https://github.com/andonLink to $https://instagram.com/sikavica