contributor-context
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/playbooks/integration/react-native-cli.md by scripts/build-agent-skill.mjs. Do not edit. -->
$ npx -y skills add crossbind/crossbind --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
<!-- GENERATED from docs/playbooks/integration/react-native-cli.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/playbooks/integration/react-native-cli.md by scripts/build-agent-skill.mjs. Do not edit. -->
> Persona 2 sub-playbook. The user's project is a bare React Native app (`react-native` in deps, no `expo`). Detection: `react-native` + `metro.config.js` + (`android/` and/or `ios/`) directories.
Add crossbind to a React Native CLI app so:
| File | Role | |------|------| | `package.json` | + `@crossbind/plugin-react-native`, `@crossbind/plugin-react-native-ios-helper` (dependencies, autolinked), `@crossbind/plugin-metro` (devDependency), optional `@crossbind/port-<name>` | | `metro.config.js` | Wrap `getDefaultConfig` output with `CrossbindMetroPlugin(...)` | | `crossbind.config.{js,mjs}` *(new at project root)* | Project-level crossbind config: deps to consume, paths | | `src/native/` *(if user wraps own C++)* | `.h` + `.cpp` source files | | `android/app/build.gradle` | Auto-wired by `@crossbind/plugin-react-native`'s native CMake hook (no manual edits) | | `ios/Podfile.lock` | Updated by `pod install` after adding the plugin | | `ios/<App>.xcodeproj` | Native iOS link picks up the auto-generated podspec |
pnpm add @crossbind/plugin-react-native@beta @crossbind/plugin-react-native-ios-helper@beta pnpm add -D @crossbind/plugin-metro@beta # bundling only; the RN plugin brings the toolchain pnpm add @crossbind/port-<name>@beta # optional # iOS — install pods (regenerates Podfile.lock + xcframeworks) cd ios && pod install && cd .. # Run on Android pnpm android # or: pnpm react-native run-android # Run on iOS pnpm ios # or: pnpm react-native run-ios
`pod install` runs build hooks from `react-native-crossbind.podspec` that compile the iOS native libraries. `pnpm android` triggers Gradle's externalNativeBuild, which calls `script/CMakeLists.txt` from `@crossbind/plugin-react-native` and shells out to `crossbind build -p android`.
Mirror `examples/mobile-reactnative-cli/`.
`metro.config.js` (canonical):
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const CrossbindMetroPlugin = require('@crossbind/plugin-metro');
const defaultConfig = getDefaultConfig(__dirname);
const config = {
...CrossbindMetroPlugin(defaultConfig),
};
module.exports = mergeConfig(defaultConfig, config);`crossbind.config.{js,mjs}` at project root:
import Matrix from '@crossbind/example-lib-prebuilt-matrix/crossbind.config.js';
// or any other prebuilt, one variant per platform:
// import gdalAndroid from '@crossbind/port-gdal-android/crossbind.config.js';
// import gdalIos from '@crossbind/port-gdal-ios/crossbind.config.js';
export default {
dependencies: [
Matrix,
// Gdal,
],
paths: {
config: import.meta.url,
},
};`.mjs` is preferred (ESM) so the `import.meta.url` reference works; `.js` is fine too if `package.json` declares `"type": "module"`.
The `examples/mobile-reactnative-cli` example keeps a snapshot of generated bridge files at `ci/crossbind-snapshot/` — the iOS workflow restores it before `pod install` to skip the SWIG bridge generation step in CI. This is **not** required for normal development, only for fast CI builds. Pattern:
my-app/
└── ci/
└── crossbind-snapshot/ ← snapshot of .crossbind/build/{bridge,interface} + cache.json
└── build/
├── bridge/
│ ├── native.i.cpp
│ └── native.i.cpp.exports.json
├── interface/
│ └── native.i
└── ...In CI, before pod install:
mkdir -p .crossbind cp -r ci/crossbind-snapshot/. .crossbind/
Don't name the snapshot dir `.crossbind` — `clear:cache:examples`-style globs may pick it up and delete it. Use a different name (`crossbind-snapshot`, `bridge-cache`, etc.).
**Not applicable.** React Native runs JS on JSC/Hermes, not in a browser, so there's no SharedArrayBuffer / COOP/COEP gate. Multithread (`runtime: 'mt'`) on RN uses pthreads via JSI directly. No header config needed for RN apps.
Import C++ and Rust like JavaScript modules (WebAssembly & React Native)
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/api/app.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/build-state.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/conan.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/cpp-binding-rules.md by scripts/build-agent-skill.mjs. Do not edit. -->