You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: on-demand native lib download with opt-in feature splitting
The npm tarball ships without prebuilt native binaries — they are
downloaded from GitHub Releases at postinstall and extracted into
third-party/, where the existing CMake / podspec configurations pick them
up unchanged. Apps can opt out of features they don't need to skip both
the download and the native compilation:
"react-native-executorch": {
"extras": ["opencv", "phonemizer", "xnnpack", "coreml", "vulkan"]
}
Defaults to all enabled. Each extra trims one or more artifacts and toggles
a corresponding RNE_ENABLE_* CMake / podspec flag, dropping its sources from
compilation and its libraries from the final link.
Per-platform behavior:
- opencv Android + iOS (iOS provided via opencv-rne CocoaPod)
- phonemizer Android + iOS
- xnnpack iOS-only as a force-loaded XnnpackBackend.xcframework;
baked into libexecutorch.so on Android
- coreml iOS-only as a force-loaded CoreMLBackend.xcframework
- vulkan Android-only as a separately-loaded
libvulkan_executorch_backend.so
Vulkan ships as its own shared library (mirroring the QNN backend pattern)
so its load-time backend registration runs only when the user opts in. The
.so links only against vulkan_backend + vulkan_schema + executorch_core,
not the CPU kernel registries, so it does not cause duplicate kernel
registration when loaded alongside libexecutorch.so.
Copy file name to clipboardExpand all lines: docs/docs/01-fundamentals/01-getting-started.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,42 @@ Installation is pretty straightforward, use your package manager of choice to in
76
76
</TabItem>
77
77
</Tabs>
78
78
79
+
### Configuring backends and extras
80
+
81
+
On install, `react-native-executorch` runs a `postinstall` script that downloads prebuilt native libraries from the matching GitHub Release and unpacks them under `third-party/`. By default every optional feature is included — which keeps the app binary large. You can opt out of anything you don't need by adding an `extras` array to your app's `package.json`:
|`xnnpack`| ✅ — `XnnpackBackend.xcframework` force-loaded into the app | ✅ — separately-loaded `libxnnpack_executorch_backend.so`| XNNPACK CPU backend (required for most quantized models) |
98
+
|`coreml`| ✅ — `CoreMLBackend.xcframework` force-loaded into the app | n/a (CoreML is iOS-only) | Core ML backend (Apple Neural Engine / GPU acceleration) |
Source files and native libraries are excluded from compilation when an extra is disabled, so builds that only need LLMs can skip OpenCV and cut tens of megabytes off the final binary.
102
+
103
+
The postinstall step honors a few environment variables:
|`RNET_TARGET`| Force a specific target, e.g. `android-arm64-v8a` or `ios`. |
110
+
|`RNET_NO_X86_64=1`| Skip the Android x86_64 tarball (handy when only building for a device). |
111
+
|`GITHUB_TOKEN`| Required to access draft releases while iterating on a new version. |
112
+
113
+
After changing `extras`, re-run `yarn install` (or the equivalent) so the postinstall script regenerates `rne-build-config.json` and re-extracts the right tarballs, then rebuild the native project.
114
+
79
115
:::warning
80
116
Before using any other API, you must call `initExecutorch` with a resource fetcher adapter at the entry point of your app:
0 commit comments