Skip to main content

Debug build

Workflow that builds the app in debug mode for Android and iOS.

This workflow can be triggered by other workflows depending on it.

info

Additionally, Debug build workflow is triggered every time new code is pushed to main branch for caching purposes. This way, every branch will be able to use the cached build. More information about cache scoping can be found here: GitHub Docs: Matching a cache key.

Usage

This workflow cannot be explicitly specified to be generated using SCI. It will be generated automatically if you choose to create workflow depending on it.

Detailed behavior

Below you can find detailed information about what the script does with your project when generating Debug Build workflow.

Fingerprint

This workflow takes advantage from the fact that debug builds need to be remade only if native code changes.

It uses @expo/fingerprint to generate a hash string of your native code (called fingerprint) to cache debug builds and create new builds only if necessary.

This logic is extracted to auxiliary reusable workflow lookup-cached-debug-build. You can find more information about it here: Lookup cached debug build.

Caching

Built apps will be cached using actions/cache using keys android-debug-build-${{ android-fingerprint }} and ios-debug-build-${{ ios-fingerprint }} (fingerprints for Android and iOS apps are different).

Note that this save a significant amount of time and resources, since changes in native code are relatively rare when developing a React Native app.

Modified and created files

FileChanges
.github/workflows/build-debug-android.ymlContains the CI workflow for building debug Android app
.github/workflows/build-debug-ios.ymlContains the CI workflow for building debug iOS app
package.json
  • New script:build:debug:android: npx expo prebuild && cd android && ./gradlew assembleDebug -DtestBuildType=debug -Dorg.gradle.jvmargs=-Xmx4g
    (npx expo prebuild is ommited in non-Expo projects)
  • New script:build:debug:ios: npx expo prebuild && xcodebuild ONLY_ACTIVE_ARCH=YES -workspace ios/[iOSAppName].xcworkspace -UseNewBuildSystem=YES -scheme [iOSAppName] -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build -quiet
    (npx expo prebuild is replaced with cd ios && pod install && cd.. in non-Expo projects)
    ([iOSAppName] is replaced with the name of the iOS app retrieved from native code)
app.jsonFields expo.android.package and expo.ios.bundleIdentifier will be created in Expo projects if not detected (they are needed for npx expo prebuild)

Workflow details

build-debug-android

The following diagram represents the flow of the build-debug-android workflow:

build-debug-ios

The following diagram represents the flow of the build-debug-ios workflow:

Known issues and limitations

  • One of limitations of GitHub Actions is that cache is scoped and cannot be accessed between arbitrary branches (see #79). This means that if a build with specific fingerprint is created on feature-a branch, then in feature-b branch with the same fingerprint, the build is not visible and the app will be built again. However, since the build is also created on main branch, once either feature-a or feature-b is merged to main, the build will be cached and available for all existing and future branches in the repository.