Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Latest commit

 

History

History
101 lines (74 loc) · 5.06 KB

build-instructions-ios-android.md

File metadata and controls

101 lines (74 loc) · 5.06 KB

Build Instructions (iOS + Android)

If there are inconsistencies with the build instructions here and the one from the official cordova docs, always favor the latter (and hopefully update the documentation here accordingly!).

As of this writing, versions are as follows:

  • Cordova v7.0.1
  • Android Studio v3.0
  • XCode 9
  • JDK 8

Preliminaries

First, make sure Cordova is installed globally (you can test by typing cordova -v):

npm install -g cordova

Prior to building for Cordova, be sure that you already built the binary webapp. You can do it by running yarn build in your project directory.

Now you can choose either to build for Android or iOS. Each of the following sections are self-contained.

Android

Setup

If this is the first time you are building the app, make sure you have gradle installed:

brew update && brew install gradle

Then add the android platform to Cordova:

cordova platform add android

This will create a platform/android folder in your project repository.

Now some notes before you install the requirements:

  • Install JDK 8 - as of this writing JDK 9 is NOT supported!
  • Make sure the API level for the SDK you choose is supported (check here) by the version of cordova you are using.
  • If you have installed android-sdk via brew, you need to uninstall it or it will conflict with android studio. To uninstall the brew version of android-sdk, enter to terminal:
rm -rf /usr/local/Cellar/android-sdk
rm -rf /usr/local/Caskroom/android-sdk
rm /usr/local/share/android-sdk
  • You can find the android sdk directory from the sdk manager itself:

    android-sdk-directory

    Your ~/.bash_profile should look something like this (place your android SDK directory in ANDROID_HOME:

export ANDROID_HOME=/Users/bruce/Library/Android/sdk/
export PATH=${PATH}:${ANDROID_HOME}platform-tools:${ANDROID_HOME}tools
  • Once you successfully installed everything, be sure to run cordova requirements android in your project directory to check that you have all the required dependencies installed.

Build & Run

To automatically build and run the app to your android device (this will install the debug version), first plug in your android device (make sure debugging mode is turned on) and enter the following:

yarn start:android

NOTE: If you see spawn EACCESS errors, run cordova build android —verbose to see which directory it fails in and do chmod 777 “<directory name that spawns EACESS>”. It is probably gradle or android-sdk.

Deploy To Playstore

Prior to deploying to playstore, you need to first increase the version number of the app via the attributes android-versionCode and version in config.xml, and version in config.js. You cannot deploy the app if android-versionCode is less than or equal to the current version in the playstore.

Once that is done, you need to build a production release of the app:

yarn build:android

If there are no errors, the build command will output a release version of the apk file. To proceed to sign the application for deployment to playstore, execute:

yarn sign:apk

iOS

Setup

First, using your binary.com email (do not use your personal email!), you will need to register an Apple ID, followed by apple developer ID, and request your manager to add you to Binary's apple developer team (just member access will do).

If this is the first time you are building the app, add the iOS platform to Cordova:

cordova platform add ios

This will create a platform/ios folder in your project repository.

Now install the requirements via the instructions in the official cordova docs.

Validate that you have everything you need by running cordova requirements ios in the project directory.

Now launch XCode, go to Preferences... and add your apple ID. If you are in the binary apple developer team, you should see more than one teams. Make sure "Binary Investments (Europe) Ltd" is one of those teams.

binary-dev-xcode

Build & Deploy

Because the ios build and run commands are pretty long, we run npm scripts instead.

To build the app, run in project directory yarn build:ios, and select "Always Allow" when CodeSign prompts to access KeyChain. This will build the release version of the app. If there are no failures, we are good to go.

To build and run the app in your device (this will install debug version), make sure your iOS device is plugged (make sure developer mode is turned on), and then run yarn start:ios.