Dev
Mobile
react-native
expo
Build Setup

Build Setup

Some Common Practices

  1. Gitignore these folder & files:
  • if there’s no native overrides / modification:
    • /android
    • /ios
  • eas.json
  • credentials.json

To Export as APK: Set Distribution as Internal

// eas.json
{
  "cli": {
    "version": ">= 7.6.1"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal"
    },
    "staging": {
      "distribution": "internal", // this will make the output as APK
      "env": {
        // Put env values here
        "EXPO_PUBLIC_API_BASE_URL": "..."
        ...
      }
    },
    "production": {
      "env": {
        "APP_NAME": "Some App Name",
        "ANDROID_PACKAGE_IDENTIFIER": "com.some.name"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

References:

  • https://docs.expo.dev/build-reference/apk/#configuring-a-profile-to-build-apks

    To generate an .apk, modify the eas.json by adding one of the following properties in a build profile:

    • developmentClient to true (default)
    • distribution to internal
    • android.buildType to apk
    • android.gradleCommand to :app:assembleRelease, :app:assembleDebug or any other gradle command that produces .apk
  • https://docs.expo.dev/build-reference/variables/#can-eas-build-use-env-files

    Environment variables defined in a .env file are only considered by the Expo CLI. Therefore, if you upload a .env file to EAS Build, it can be used to inline EXPOPUBLIC variables into your application code.

    However, the recommended practice is to use .env files in your local environment, while defining environment variables for EAS Build in eas.json. Environment variables defined in your eas.json build profile will be used when evaluating your app.config.js when running eas build and will be available to all steps of the build process on the EAS Build server.