Security & Distribution - GrasspIt/GrasspReactNativeDriverApp GitHub Wiki

Security

The package expo-secure-store encrypts and stores key-value pairs locally. This app uses SecureStore for the auth token from Grassp API.

The environment.tsx file is used for determining the api url to use in different environments. (i.e. development, staging, or production)

Use of the Google Maps API key is restricted to the Grassp App identifier as added security.

Distribution

Release channels determine whether the staging or production api will be used with the app. The release channel is set anytime the app is built or published.

Creating New Builds

App builds are managed through Expo for both Android and iOS.

Before building the app, update version and versionCode properties in app.json.

To do a production build for Android, run expo build:android --release-channel prod* and follow the prompts.

  • For a standard build to upload to AppHost, choose the APK build option when prompted. This will produce an IPA file.

When the build is complete, download the APK file from Expo (a link to download will also be provided in the terminal).

For iOS, run expo build:ios --release-channel prod* and follow the prompts using the AppleID login information.

  • For a standard build to upload to AppHost, choose the Archive option when prompted. This will produce an IPA file.

When the build is complete, download the IPA file from Expo (a link to download will also be provided in the terminal).

Notes

*To use the staging API instead, replace prod with staging in the above commands.

A new build is required with any of the following changes in the app.json file:

  • Increment the Expo SDK Version
  • Change anything under the ios, android, or notification keys
  • Change your app splash
  • Change your app icon
  • Change your app name
  • Change your app owner
  • Change your app scheme
  • Change your bundled assets under assetBundlePatterns

Publishing Updates

To publish changes after the initial build for both Android and iOS, run expo publish --release-channel prod.

Installed apps should receive over-the-air updates through Expo.

New updates should automatically install next time the user opens the app.

Distributing the App

The Grassp Driver App is distributed through AppHost, which is a third-party SaaS website providing free hosting and distribution for enterprise apps.

After creating a new build, upload the APK and IPA files to generate a single link for both Android and iOS.

The software detects the device's operating system and provides platform-specific instructions for downloading the app.

Debugging your build

The following is based on Expo's guide to debugging production errors.

Because it is difficult to debug distributed builds, it is recommended to see if you can reproduce the error locally.

But what if my error is not reproduced in my local environment?

  • One solution is to run the app in 'production mode' locally with the following command: expo start --no-dev --minify.
    • "--no-dev" tells the server not to be run in development mode, and "--minify" will minify your code the same way it is for production JavaScript bundles

Strategies for Production App Crashes

One good strategy for debugging a build that keeps crashing is to access the native device logs.

The amount of information from these logs can be overwhelming at first. Clear the logs before opening the app. After the app crashes, search the logs for the term "fatal exception". Stack Overflow is a great resource for understanding how to solve these exceptions.