## Building Application Binaries

Building standalone IPA (iOS) and APK (Android) binaries utilizes the Expo 
[`turtle-cli`](https://docs.expo.io/versions/latest/distribution/turtle-cli) library.

This library, in turn, requires that you have [Fastlane](https://fastlane.tools/) installed.

### Install Dependencies

Install `turtle-cli` and Fastlane:
    
    bundle install
    yarn global add turtle-cli
    
If you don't have the `bundle` command available, you will have to install it via 
`gem install bundler`.

### Certificates

Certificate files are required to sign application binaries for distribution to app stores. These
should be placed within the `.certs` directory of the project root. iOS binaries require a
provisioning profile, as well as p12 files for distribution and push notifications. Android
binaries only require a keystore file (`.jks`). The `.certs` directory should have all of the 
following files available to build dev, qa and prod binaries for both iOS and Android:

    .
    └── .certs
        ├── orchardgo-dev.jks
        ├── orchardgo-dev.mobileprovision
        ├── orchardgo-dev_dist.p12
        ├── orchardgo-dev_push.p12
        ├── orchardgo-prod.jks
        ├── orchardgo-prod.mobileprovision
        ├── orchardgo-prod_dist.p12
        ├── orchardgo-prod_push.p12
        ├── orchardgo-qa.jks
        ├── orchardgo-qa.mobileprovision
        ├── orchardgo-qa_dist.p12
        └── orchardgo-qa_push.p12

### Environment Variables

The following environment variables are required for building both iOS and Android binaries:
* `ENV` - the build environment. This should be set to either `dev`, `qa`, or `prod`.
* `EXPO_USERNAME` - the username for Expo.
* `EXPO_PASSWORD` - the password for Expo.
    
The following environment variables are required for building iOS binaries:
* `APPLE_TEAM_ID` - the Apple team identifier. You can find this 
[here](https://developer.apple.com/account/#/membership).
* `EXPO_IOS_DIST_P12_PASSWORD` - the password for the iOS distribution certificate.
* `EXPO_IOS_PUSH_P12_PASSWORD` - the password for the iOS push notification certificate.
    
The following environment variables are required for building Android binaries:
* `ANDROID_KEYSTORE_ALIAS` - the alias for the Android keystore.
* `EXPO_ANDROID_KEYSTORE_PASSWORD` - the password for the Android keystore.
* `EXPO_ANDROID_KEY_PASSWORD` - the password for the Android distribution key.
    
### Yarn Targets

Once the proper certificates and environment variables are put into place, you can use the
following yarn tasks to build binaries for iOS and Android respectively:

    yarn build:ios
    yarn build:android
    
