Release builds and symbolication

What is readable in a React Native release build — JavaScript stack traces from Hermes bundles, R8 mappings on Android, dSYMs on iOS — what Sophonz can resolve today, and a Gradle plugin interaction to avoid.

A release build of a React Native app has three kinds of frames that need resolving: JavaScript frames in a minified bundle, Java and Kotlin frames shrunk by R8, and native frames on iOS and in C++ libraries. Sophonz resolves R8 frames and iOS native frames from uploaded files. JavaScript source maps have no upload path yet; this page says what to keep so you can resolve JavaScript frames yourself.

At a glance

FramesResolved by SophonzWhat to uploadHow
JavaScript (Hermes or JSC bundle)No—Keep the source map; resolve locally
Android Java/Kotlin (R8)Yesmapping.txt@sophonz/cli upload-mapping
iOS nativeYesdSYM bundles@sophonz/cli upload-dsym or a build phase

JavaScript stack traces

Unhandled exceptions, handled errors and warning or error logs carry the JavaScript stack as a string: spz.stacktrace.rn on logs, and on iOS spz.ios.react_native_crash.js_exception on unhandled exceptions. In a release build these are positions in the bundle — for Hermes, bytecode offsets such as index.android.bundle:1:284511 — not your source files.

Sophonz does not store React Native source maps. @sophonz/cli upload-sourcemaps is for the browser SDK: it files maps under a web version and a script URL, which a React Native bundle has neither of. Until there is a React Native upload path, keep the source map of every release you ship and resolve stack traces with Metro's symbolicator.

Keep the source map

Android: the React Native Gradle plugin writes the composed Hermes source map during a release build.

android/app/build/generated/sourcemaps/react/release/index.android.bundle.map

iOS: set SOURCEMAP_FILE in the Bundle React Native code and images build phase, before the script runs.

export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map"

Archive the map as a CI artifact next to the build, named with the app version, build number and the JavaScript patch if you ship over-the-air updates.

Resolve a trace

Copy the stack from the log attribute into a file and run:

npx metro-symbolicate index.android.bundle.map < stacktrace.txt

The map must come from the exact build that produced the trace. On iOS release builds, react_native_bundle_id (the MD5 of main.jsbundle) tells you which bundle that was; set patch in initialize so over-the-air updates can be told apart on both platforms.

Android: R8 mapping

React Native's release build type has minifyEnabled off by default (enableProguardInReleaseBuilds = false in android/app/build.gradle). If you turn it on, upload each build's mapping.txt:

export SOPHONZ_TOKEN=sophonz_pat_...
 
npx @sophonz/cli upload-mapping \
  --file android/app/build/outputs/mapping/release/mapping.txt \
  --version 1.4.0

--version is the versionName of the build. Options, the upload API and how matching works are in Android mapping file upload.

WARNING — Setting api_token in a React Native app

The Gradle plugin can upload mappings by itself when api_token and app_id are set in sophonz-config.json. In a React Native app, that same setting also registers a React Native source map upload for every release variant, which posts to /v2/store/sourcemap — an endpoint the Sophonz server does not have. With the plugin's default failBuildOnUploadErrors = true, that upload fails the release build.

Use the CLI instead, and leave api_token out of sophonz-config.json. If you do use the plugin's upload, set this in android/app/build.gradle so the failing request does not stop the build:

sophonz {
  failBuildOnUploadErrors.set(false)
}

This behaviour is read from the Gradle plugin's source for 1.0.0; it has not been exercised against a React Native release build.

iOS: dSYMs

Native frames in iOS crash reports — your Swift and Objective-C code, React Native, Hermes and other pods — are resolved from dSYM bundles. With the Release configuration's Debug Information Format set to DWARF with dSYM File (the default), upload after archiving:

npx @sophonz/cli upload-dsym \
  --file "$DWARF_DSYM_FOLDER_PATH" \
  --version 1.4.0 \
  --build-id 120

Pods built from source, including SophonzIO, produce their own dSYMs, and passing the folder uploads all of them. The Xcode build phase, GitHub Actions and curl variants are in iOS dSYM upload.

Checklist for a release

  • Android: minSdk and desugaring pass the Gradle plugin's checks; the release sophonz-config.json has the production service_key.
  • iOS: the production key is in SophonzInitializer.swift, sdkConfig.ios or Sophonz-Info.plist — whichever this app uses.
  • initialize is called with patch if you ship over-the-air updates.
  • Source maps, mapping.txt and dSYMs from this exact build are archived or uploaded.
  • debug={false} on the navigation tracker, and configureSDKErrorLogging off or routed to your own handler.