build-compilation-dependencies
Skill864 starsChanged 7 days agoMITView on GitHub
Build system overview for react-native-audio-api across all platforms — CMakeLists.txt, android/build.gradle, RNAudioAPI.podspec, Package.swift (SwiftPM), prebuilt external libraries, and the standalone C++ test build. Use this skill when adding a new source file, modifying CMakeLists or podspec, debugging compilation errors, integrating a new dependency, or understanding why includes work differently in tests vs the app. Trigger phrases: "add source file", "CMakeLists", "podspec", "build.gradle", "prebuilt binaries", "FFmpeg disabled", "pod install", "new architecture", "compile error", "undefined symbol", "SIMD", "worklets build flag", "C++ tests", "conditional compilation", "include path", "gradle build fails", "link error", "pnpm catalog", "catalog:", "add a dependency", "bump a dependency", "pnpm workspace", "minimumReleaseAge", "allowBuilds", "overrides", "shared dependency version", "undeclared dependency", "phantom dependency", "Package.swift", "SwiftPM", "Swift Package Manager", "react-native spm".
- Deletes or force-pushes
- Installs packages
In this repository13 other files it gives its agents.
- apps/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/expressive-code.mdcCursor rule
- audio-nodesSkill
- expressive-codeSkill
- flowSkill
- host-objectsSkill
- post-work-checksSkill
- thread-safety-itcSkill
- turbo-modulesSkill
- utilitiesSkill
- web-audio-apiSkill
- writing-skillsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 164
These directories are gitignored: If they're missing, run pod install (iOS) or Gradle build (Android) to re-download them.
- Distinctive: line 239
Keep it in sync with the podspec.
- Very specific: line 259
Verify in throwaway apps on the oldest (0.87.x) and newest supported RN: @react-native-community/cli init … --version <exact x.y.z> (a bare …
- Very specific: line 283
After pnpm install (any dependency change)
- Distinctive: line 285
After adding/removing iOS source files that need to be picked up
- Very specific: line 287
When prebuilt binaries need to be re-downloaded (podspec prepare_command runs on pod install)
- Very specific: line 346
Before --android or --ios, the script runs once:
- Distinctive: line 504
If that reproduces the error, the database is wrong — not the editor's LSP setup.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: Build, Compilation & Dependencies
For deep CMake/Gradle/podspec analysis see build-details.md.
Repository Build Overview
react-native-audio-api/
├── package.json # pnpm workspace root (packages listed in pnpm-workspace.yaml)
├── packages/react-native-audio-api/ # Main library
│ ├── android/
│ │ ├── build.gradle # Android build config (Gradle)
│ │ ├── CMakeLists.txt # Android CMake root (delegates to subdirectory)
│ │ └── src/main/cpp/audioapi/
│ │ └── CMakeLists.txt # Actual Android C++ build target
│ ├── common/cpp/audioapi/ # Shared C++ (used by all platforms)
│ │ ├── decoding/ # Decoder factory, backends, SeekDecoderDaemon, AudioDecoding
│ │ ├── encoding/ # AudioEncoder interface, EncoderCapabilities, OS encoder/remux selector headers, AudioFileConcatenator, AdtsHeader (ADTS framing)
│ │ ├── libs/ # Third-party wrappers (FFmpeg, miniaudio, pffft, …)
│ │ └── external/ # Prebuilt binaries per platform
│ │ ├── android/ # .a static libs (Opus, Ogg, Vorbis, OpenSSL)
│ │ ├── xcframeworks/ # Every iOS prebuilt as <lib>.xcframework (static Opus/Ogg/Vorbis, dynamic FFmpeg)
│ │ ├── include/ # Headers for Opus/Ogg/Vorbis/OpenSSL
│ │ └── include_ffmpeg/ # FFmpeg headers (downloaded, FFmpeg builds only)
│ ├── common/cpp/test/
│ │ ├── CMakeLists.txt # Standalone test build (no Android/iOS)
│ │ ├── run-tests.sh / filters.sh # smoke|extended|full|affected (+ categories, suite paths)
│ │ └── src/ # Google Test files
│ ├── RNAudioAPI.podspec # CocoaPods spec for iOS
│ ├── Package.swift # SwiftPM manifest for RN's `react-native spm` mode
│ ├── ios/spm/ # SwiftPM-only wrapper sources + empty public-header dirs
│ └── scripts/
│ ├── download-prebuilt-binaries.sh # Downloads externals from GitHub Releases
│ └── rnaa_utils.rb # Ruby helpers for podspec (path resolution)
└── apps/
└── fabric-example/
└── ios/
└── Podfile # Consumer Podfile (new arch enabled)pnpm Workspace & Dependency Catalog
The workspace packages, the dependency catalog, overrides, the release-age gate and the
build-script allowlist all live in the root pnpm-workspace.yaml. Catalogued versions are
referenced from manifests as "<dep>": "catalog:". Bump once there and every workspace
follows. The pnpm version is pinned exactly in the root package.json packageManager.
Every package declares what it imports. pnpm's layout is isolated: a package only sees its own declared dependencies, so an undeclared import fails at install-time resolution (Metro, tsc, Node) instead of working by accident through hoisting. This is deliberate: undeclared imports shipped in 0.13.3 (#1267) and broke users' bundling. Fix such an error by declaring the dependency in the package that imports it, never by adding it to the root.
What belongs in the catalog — anything that must move in lockstep, which is broader than "used more than once":
- used by two or more workspaces, or
- version-locked to something already catalogued even if only one workspace uses it —
react-test-renderermust equalreact;@react-native-community/cli*and@babel/runtimemove withreact-native/@babel/core.
A dependency used in exactly one workspace with no such coupling stays a literal range: it has no second copy to drift from, and catalogue membership is meant to signal "keep this in lockstep". There is no CI check enforcing this — review is the enforcement, which is why membership has to carry meaning.
Workflow when touching dependencies:
- Changing the version of a catalogued dep → edit the catalog entry, not the manifest.
- Adding a dep → check the catalog first. Already there? Use
"catalog:". Not there but lockstep-coupled or now used twice? Add the entry and switch both call sites over.
Three kinds of dependency must never be given catalog::
| Never catalogue | Why |
peerDependencies | Public API surface of the published packages, deliberately loose ("*"). Pinning narrows what consumers may install. |
Runtime dependencies of published packages (semver, chalk, commander, fs-extra) | The release pipeline packs with npm pack (scripts/create-package.sh, npm-custom-node-generator-build.yml) and npm does not understand catalog:. It publishes the literal string, producing an uninstallable package. Only pnpm pack / pnpm publish perform the swap. |
workspace:* ranges | Not version ranges — nothing to centralise. |
Other constraints:
overridespinstypescriptliterally; keep it in sync with the catalog entry. It is not redundant with the catalog: without it, commitlint 17's optionaltypescriptpeer (^4.6.4 || ^5.2.2, via@commitlint/load,cosmiconfig-typescript-loaderandts-node) installs a second TypeScript (5.9.3), because catalogs only rewrite workspace manifests, never transitive dependencies. Apnpm install --lockfile-onlydry run does not show the extra copy; a real install does. Recheck once commitlint is bumped.- TypeScript is 7 (the Go compiler): the
typescriptpackage has no JavaScript API (require('typescript')exports onlyversion), so nothing may callts.transpileModule& co. — typescript-eslint cannot load, which is why linting is oxlint. TS 7 also rejectsbaseUrl; the docs tsconfigs set"baseUrl": nullto cancel the one@docusaurus/tsconfigsets and re-declare@site/*. - oxlint loads its JS plugins from the config's own directory:
eslint-plugin-tsdoc(root.oxlintrc.json) is a root devDependency andeslint-plugin-react-native(nestedapps/common-app/.oxlintrc.json) a common-app one. A plugin installed only in another package does not resolve. - The docs sites (
audiodocs,internaldocs,docs-theme) are workspace packages. They takereact/react-domfrom the catalog (React requires the two to match exactly) and linkdocs-themewithworkspace:*. audiodocs pins an exact publishedreact-native-audio-apiversion on purpose: its demos run the npm release, never the workspace source. CI installs them alone withpnpm install --filter <site>..., which skips building the library. - Docusaurus is pinned to exactly 3.9.2 in every
@docusaurus/*entry (a^range let one plugin drift to 3.10 and broke the build) because@swmansion/t-rex-uirequires 3.9.2. Thewebpack: 5.101.3override exists because Docusaurus 3.9 breaks on webpack ≥ 5.102; drop both once t-rex-ui supports 3.10. - Packing goes through
npm pack, notpnpm pack.yarn packdroppeddevelopment/react/(a nestedpackage.jsonlisted infiles[]) and stripped the executable bit from 29 prebuilt FFmpeg binaries;pnpm packhas not been verified. Do not switch the release pipeline without re-verifying the tarball contents.
Install scripts run only for packages listed under allowBuilds (lefthook, which installs the
git hooks, and esbuild for the docs; core-js is explicitly denied, it only prints a funding message). A new dependency with a build script fails pnpm install with
ERR_PNPM_IGNORED_BUILDS until it is allowed (true) or explicitly denied (false) there.
Supply-chain gate: minimumReleaseAge: 10080 (minutes) refuses versions published in the
last 7 days. Exempt specific packages via minimumReleaseAgeExclude in pnpm-workspace.yaml.
C++ Header File Extensions
In common/cpp/audioapi/: .hpp = header-only templates; .h = non-template (usually with a .cpp). Vendored code is excluded.
Prebuilt Binaries
External libraries (Opus, Ogg, Vorbis, OpenSSL, FFmpeg) are not compiled from source — they are downloaded as prebuilt .a / .so / .xcframework archives from:
https://github.com/software-mansion-labs/rn-audio-libs/releases/download/<TAG>/The tag is TAG in scripts/download-prebuilt-binaries.sh; Package.swift pins the same one (prebuiltBinariesTag) plus one SwiftPM checksum per xcframework. Bump all of them from an rn-audio-libs checkout:
gh release download <tag> -R software-mansion-labs/rn-audio-libs -p checksums.txt -D <dir>
yarn bump:rn-audio-api <tag> <dir>/checksums.txt <this repo><tag>: the rn-audio-libs release, e.g.v5.0.0-rc.1.checksums.txt: an asset of that release, one<name> <sha256>line per xcframework. Any folder works;-Djust keeps it out of the rn-audio-libs tree.<this repo>: the root of this repository, notpackages/react-native-audio-api.
The download script is triggered automatically:
FFmpeg is opt-in (off by default). All build options (enableFFmpeg, disableStaticExternalLibs, disableAudioRecorder) come from the "react-native-audio-api" section of the app's package.json on every path: podspec (rnaa_utils.rb read_audio_api_build_options, <Podfile dir>/../package.json), Gradle (readAudioApiBuildOptions, rootProject.projectDir.parentFile), Package.swift (walk from the autolinking symlink). The 0.13 inputs (Podfile ENV[...], gradle.properties keys) are simply not read any more — no guard, by decision: it ships in a major. Non-boolean values are errors. The Expo plugin (src/plugin/withAudioAPI.ts) still accepts enableFFmpeg / disableStaticExternalLibs (BUILD_OPTION_KEYS), deprecated (removal planned for the next major; each prebuild adds a WarningAggregator warning), and only as a writer: a withDangerousMod on both platforms (so a single-platform prebuild still runs it; idempotent) merges the given keys into the app package.json section during expo prebuild, keeping the file's indentation, before prebuild's pod install. Omitted options leave package.json alone; the builds never read the plugin options themselves. New build options are package.json-only and are not added to the plugin (disableAudioRecorder is not a plugin option). The pre-1.0 DISABLE_AUDIOAPI_FFMPEG / disableAudioapiFFmpeg / disableFFmpeg flags are not read any more and produce no warning either: a leftover disable flag asks for the default, so there is nothing to tell the user, and the switch is covered by the separate upgrade docs page (planned, not written yet). Migration notes belong on that page only — feature pages such as build-time-flags.mdx (the one docs page for every build option and the prebuilt libraries they toggle; there is no separate prebuilt-libraries page any more) describe the current behaviour without "Upgrading from…" notes. Internally every build file and source keys off the positive $RN_AUDIO_API_FFMPEG_ENABLED / RN_AUDIO_API_FFMPEG_ENABLED. The define is only emitted (=1) in an FFmpeg build; #if RN_AUDIO_API_FFMPEG_ENABLED reads an undefined macro as 0, so the test, clangd and WPT builds do not mention it at all. The download script passes skipffmpeg in the default build, so neither the .so/xcframeworks nor (once published) the include_ffmpeg.zip header archive are fetched.
disableAudioRecorder keeps App Store Connect's static scan (ITMS-90683) from demanding NSMicrophoneUsageDescription in playback-only apps. It defines RN_AUDIO_API_AUDIO_RECORDER_DISABLED=1 and excludes AudioRecorderHostObject.cpp plus the platform recorder: IOSAudioRecorder.mm and NativeAudioRecorder.m (podspec and Package.swift), AndroidAudioRecorder.cpp (android/src/main/cpp/audioapi/CMakeLists.txt). Kotlin reads BuildConfig.RN_AUDIO_API_AUDIO_RECORDER_DISABLED and, in AudioAPIModule.kt, rejects the recording-permission promises and refuses showNotification("recording", …) (iOS has no recording notification). CocoaPods exclude_files is per subspec and not inherited, so the .mm/.m exclusions sit on the nested ios subspec. With the sources gone, createPlatformAudioRecorder has no iOS definition, so nothing compiled may reference it: AudioAPIModuleInstaller.h guards the AudioRecorderHostObject include and makes createAudioRecorder throw a jsi::JSError. Its functions are inline, so only a translation unit that calls injectJSIBindings (the platform AudioAPIModule) emits recorder references; it is also kept out of the Android prefab (audioApiPrefabHeaderExcludes). createRecorderAdapter needs no guard: since 1.0 it is not public, and its only caller, AudioRecorder.connect, cannot be reached without a recorder. AudioSessionManager.mm compiles out the record-permission APIs (the promise methods reject with E_RECORDER_DISABLED, the same code Kotlin uses; the synchronous requestRecordingPermissions / checkRecordingPermissions are declared only in recorder builds, since IOSAudioRecorder.mm is their only caller) and AudioEngine.mm compiles out every AVAudioEngine.inputNode / AVAudioSinkNode use. New code that touches the microphone must sit behind the same define (or the BuildConfig field in Kotlin).
- iOS: by podspec
prepare_commandduringpod installand by ascript_phase([CP-User] Download RNAudioAPI prebuilt binaries,:before_headers, always-out-of-date) on every Xcode build — downloads one<name>.xcframework.zipper library (plusinclude_ffmpeg.zipwith FFmpeg).prepare_commandensures all vendored.xcframeworks exist when CocoaPods generates[CP] Copy XCFrameworks. The build-time phase handles CI setups that cachePods/independently fromnode_modules/— it is a fast no-op when binaries are already present. It must use:before_headers, not:before_compile— CocoaPods inserts its own[CP] Copy XCFrameworksphase right afterHeaders;:before_compilewould land after it. The phase'soutput_filesdeclares every vendored xcframework. The whole phase is skipped only whenDISABLE_AUDIOAPI_STATIC_EXTERNAL_LIBSis set and FFmpeg is not enabled. - Android: by
downloadPrebuiltBinariesGradle task, which runs beforepreBuild— downloadsandroid,jniLibs
The script is idempotent — it skips any archive whose expected artifacts exist (artifacts_present) and came from the pinned TAG (archive_is_current), so the per-build invocations are fast no-ops once binaries are present. After each extraction it writes the tag to external/.prebuilt-tags/<extracted name> (outside the extracted folders, since jniLibs/ must hold only native libs); a missing or different stamp replaces that archive, removing its old folder first so files a release dropped do not linger. Before the stamps, a TAG bump never reached a checkout that already had binaries. A failed download leaves the existing files and stamp untouched; a failed extraction (unzip exit > 1: corrupt zip, full disk) removes the half-extracted folder and exits 1 without stamping. Anything that caches the extracted folders (the Cache prebuilt binaries steps in .github/workflows/native-build.yml) must cache external/.prebuilt-tags with them, or every cache hit re-downloads everything. A failed download is retried (download_with_retry: 3 attempts, 5 s apart, for transient GitHub 5xx errors and dropped connections) and then a hard error (exit 1): a silent skip used to surface much later as a missing header or undefined symbol.
One run at a time per package folder. Every run shares scripts/audioapi-binaries-temp (deleted when a run ends) and both platforms extract external/include_ffmpeg, so an iOS and an Android build started together in the same checkout, or two monorepo apps sharing one installed package, can delete each other's files and fail with Download failed … after 3 attempts. Sequential builds, EAS cloud, eas build --local and separate CI runners never overlap. The failure is loud and a rerun fetches only what is missing. Left unfixed by decision; if users report it, serialize runs with a mkdir lock in scripts/ (no flock on macOS) holding the owner pid so a lock left by kill -9 can be taken over.
FFmpeg headers. external/include_ffmpeg/ is not tracked: it is gitignored, negated in package.json files, and fetched as include_ffmpeg.zip from the pinned rn-audio-libs release in the same pass as the FFmpeg binaries (FFMPEG_HEADERS_ARCHIVE, presence checked through FFMPEG_HEADER_MARKERS, skipped with skipffmpeg). The archive is produced by yarn export (scripts/pack_outputs.sh) in rn-audio-libs, which zips every outputs/* directory except include, so a new release of that repo ships the headers automatically — but every tag the download script pins must carry the asset or FFmpeg builds fail at the download step. Nothing else references the directory outside the gated include-path entries (podspec pod_target_xcconfig, Android CMake); common/cpp/clangd/CMakeLists.txt adds the path unconditionally, so in a checkout that never enabled FFmpeg clangd shows unresolved libav* includes only inside FfmpegDecoder.cpp. FfmpegDecoder.h includes libav* directly, but DecoderFactory.cpp is the only consumer and gates that include behind RN_AUDIO_API_FFMPEG_ENABLED, every disabled build also drops FfmpegDecoder.cpp, and the Gradle prefab header copy excludes audioapi/external/**.
Downloaded artifacts land in:
common/cpp/audioapi/external/android/<ABI>/—.astatic libs for Android ABIsandroid/src/main/jniLibs/<ABI>/— FFmpeg.soshared libs for Android (loaded at runtime)common/cpp/audioapi/external/xcframeworks/— every iOS prebuilt as<lib>.xcframework(static Opus/Ogg/Vorbis, dynamic FFmpeg) (each release zip unpacks to exactly that directory). Older checkouts may still hold the pre-v4.0.0ffmpeg_ios/,iphoneos/,iphonesimulator/,macosx/— unused and gitignored
These directories are gitignored. If they're missing, run pod install (iOS) or Gradle build (Android) to re-download them. Do not commit them.
Android Build — high-level summary
Files
android/build.gradle— Gradle library configandroid/fix-prefab.gradle— prefab publication workaround (ported from react-native-worklets)android/CMakeLists.txt— Android CMake root (SIMD detection, RN version flags, delegates to subdirectory)android/src/main/cpp/audioapi/CMakeLists.txt— actual build target (sources, prebuilt libs, include paths)common/cpp/audioapi/EXTENSION_API.md— stable C++ extension contract for dependent native modulescommon/cpp/audioapi/compatibility/StableAPI.h— single public C++ compatibility header for extensions
Key behaviors
newArchEnabledis read from the app'sgradle.propertiesand defaults to on: only an explicitnewArchEnabled=falsebuilds the legacy path, because RN 0.82+ apps no longer declare the property (the podspec likewise treats onlyRCT_NEW_ARCH_ENABLED=0as legacy);enableFFmpeg/disableStaticExternalLibs/disableAudioRecorderfrom the app'spackage.json(readAudioApiBuildOptions); all are forwarded to both CMake and KotlinBuildConfig- Source exclusion in
android/src/main/cpp/audioapi/CMakeLists.txtmust uselist(FILTER … EXCLUDE REGEX)—COMMON_CPP_SOURCESholds paths relative to that directory, so alist(REMOVE_ITEM …)with an absolute path silently matches nothing (this is how the FFmpeg exclusion was a no-op for a long time) - Third-party include dirs (
external/include,external/include_ffmpeg) are only added when the corresponding library set is enabled - DSP sources always compiled with
-O3regardless of overall build type - Sources gathered with
GLOB_RECURSE CONFIGURE_DEPENDS— CMake re-runs automatically when files are added/removed - 16KB page size alignment enabled for Android 15+
- Extension API (prefab): single public C++ header
<audioapi/compatibility/StableAPI.h>; prefab publishes everyaudioapi/**/*.{h,hpp}header fromcommon/cppandandroid/src/main/cpp, minusaudioApiPrefabHeaderExcludes(external/**,AudioAPIModuleInstaller.hand the JNIandroid/AudioAPIModule.hthat includes it; one list applied to both directories), like react-native-worklets (prepareAudioApiHeadersForPrefabs, aCopytask, so a deleted header stays staged until a clean build); a type an extension needs gets added toStableAPI.hand its table inEXTENSION_API.md;fix-prefab.gradleensures the.sois in prefab metadata. Contract:EXTENSION_API.md - CMake exposes
COMMON_CPP_DIRandANDROID_CPP_DIRas PUBLIC include dirs so prefab consumers resolve<audioapi/...> - React Native's transitive Kotlin/Java deps are usable without declaring them.
ReactAndroiddeclares several libraries withapi(...)rather thanimplementation(...), so they reach us through the existingimplementation "com.facebook.react:react-native:+". Fresco is the notable one (com.facebook.fresco:fresco— 3.2.0 on RN 0.76, 3.7.0 on RN 0.87), used bysystem/notification/ArtworkLoader.kt. Check the RN version'sReactAndroid/build.gradle.ktsbefore adding a dependency that RN may already expose; adding it explicitly only risks a version conflict. - Verify any such API at the RN floor, not just the checked-in version.
android/build.gradleasserts RN minor >= 76, so a Kotlin API that exists innode_modulestoday may not exist at 0.76. Fresco's API surface happens to be identical across 3.2.0-3.7.0, but the thirdResizeOptionsconstructor parameter was renamed (maxBitmapSize->maxBitmapDimension), so positional arguments are required. Sources for a given version are fetchable fromraw.githubusercontent.com/facebook/{react-native,fresco}/v<tag>/....
For full per-line analysis see build-details.md.
iOS Build (CocoaPods) — high-level summary
Files
RNAudioAPI.podspec— library spec with subspecsscripts/rnaa_utils.rb— Ruby helpers called by podspecapps/fabric-example/ios/Podfile— consumer
Key behaviors
- Four subspecs split compilation:
audioapi(core C++),audioapi/ios(ObjC++),audioapi/audioapi_dsp(DSP with-O3),audioapi/miniaudio_impl(compiled as-x objective-c++) - Every prebuilt (static Opus/Ogg/Vorbis, dynamic FFmpeg) is an
.xcframeworkins.ios.vendored_frameworks(named after the library: CocoaPods links a dynamic xcframework as-framework <xcframework name>) — the same release assets Package.swift downloads; CocoaPods picks the device/simulator/Catalyst slice and embeds the dynamic ones. The pre-v4.0.0 per-SDK.adirs (iphoneos/,iphonesimulator/,macosx/) and their-force_load …/$(PLATFORM_NAME)flags are gone - CocoaPods never links a pod's own vendored dynamic xcframeworks into the pod's own target (only into targets that depend on it). Under
use_frameworks! :linkage => :dynamicRNAudioAPImust link FFmpeg itself, so the podspec addsffmpeg_ldflagstopod_target_xcconfigOTHER_LDFLAGS(FFmpeg builds only). Build the xcframework list and the flags from the sameffmpeg_libs; see build-details.md Accelerateframework linked, enablingHAVE_ACCELERATE=1for vDSP SIMD on iOS- Header search paths split:
pod_target_xcconfig(library compilation) vsxcconfig(app consumers) rnaa_utils.rbresolves dynamic paths atpod installtime (not hardcoded)- JSI internals use distinct names (
HostObject,RuntimeInstanceCache,RuntimeObserver) instead of generic names likeJsiHostObject/RuntimeAwareCache/RuntimeLifecycleMonitor—react-native-skiapublishes headers with those generic names and CocoaPods can resolve the wrong file when both libraries are in the same app - An intermittent
pod installfailureArgumentError - pathname contains null byte(CocoaPodsproject.rb,base_path.realdirpath) is Ruby bug #22479.File.realdirpathcan return a corrupted path for paths behind pnpm's relativenode_modulessymlinks when GC runs mid-call. The fabric-example Podfile patchesPathname#realdirpathto userealpathfor existing paths. Remove the patch once CI's Ruby includes the fix (3.4.13+ / 4.0.10+). Upgrading CocoaPods, pinning Ruby 3.2, or cleaning Pods does not fix it.
For full per-line analysis see build-details.md.
Include our own headers by full path (<audioapi/ios/system/AudioEngine.h>), never bare
(<AudioEngine.h>): CocoaPods' header map resolves bare names, SwiftPM does not.
iOS Build (SwiftPM) — Package.swift
React Native's experimental npx react-native spm mode (0.87+) symlinks each library to
<app>/ios/build/generated/autolinking/libs/<SwiftName>/ and resolves our hand-written
Package.swift from there — hence the fixed relative paths ../../../../xcframeworks (ReactNative
headers-only package) and ../../../ios (React-GeneratedCode, which serves <rnaudioapi/rnaudioapi.h>).
It only builds inside such an app.
The package and its library product must both be named ReactNativeAudioApi. Autolinking emits
.product(name: X, package: X) for a library's Swift name X. 0.88+ takes X from swiftpmConfig.name in
package.json, then the deprecated spm.name in react-native.config.js. 0.87 reads only spm.name and
otherwise derives X from the npm name (react-native-audio-api → ReactNativeAudioApi). Setting
swiftpmConfig.name to that derived name makes both versions agree without a react-native.config.js
(0.88 would warn that spm is deprecated). A different name breaks 0.87 with "product 'ReactNativeAudioApi'
… not found". The internal targets keep the RNAudioAPI / RNAudioAPIDSP names. Verified 2026-10-19 on
0.87.1 and 0.88.0.
Keep it in sync with the podspec; how each podspec feature maps:
| Podspec | SwiftPM |
miniaudio_impl subspec (-x objective-c++) | ios/spm/sources/MiniaudioImplementation.mm includes the .cpp; the .cpp is excluded |
EXCLUDED_SOURCE_FILE_NAMES[config=Release] AudioThreadGuard.cpp | ios/spm/sources/AudioThreadGuardDebug.cpp wraps it in #ifdef DEBUG |
audioapi_dsp subspec (-O3) | separate RNAudioAPIDSP target with .unsafeFlags(["-O3"]) |
vendored_frameworks, include_ffmpeg | remote .binaryTarget(url:checksum:) per library — the same zips (a binary target is named after its xcframework, so the targets are plain libopus, libavcodec, …); FFmpeg headers ship as the header-only FFmpegHeaders.xcframework (stub lib + Headers/) because the FFmpeg frameworks carry none. SwiftPM rejects $(…) macros in unsafeFlags, so per-SDK .a linking is impossible |
prepare_command download | none — SwiftPM downloads and checksum-verifies the zips while resolving. Assets come from rn-audio-libs scripts/pack_spm_xcframeworks.sh; bump prebuiltBinariesTag and every checksum together |
package.json build options (rnaa_utils.rb) | the same "react-native-audio-api" section, found by walking up from the autolinking symlink; booleanOption() rejects non-booleans. No env vars: Xcode re-resolves packages without the shell env |
- Every non-source file under
common/cpp/audioapi(.mddocs so far) must be listed inmainTargetExcludes. Not fatal, tested 2026-10-19: without the excludes the build succeeds but Xcode shows "no rule to process file … of type 'file'" once per file per architecture in every SwiftPM app. SwiftPM has no globs, so add each new doc file by path. DEBUG=1/NDEBUGper configuration are mandatory: the prebuilt React framework's C++ ABI depends onNDEBUG.publicHeadersPathpoints at the emptyios/spm/include/ios/spm/dsp-include(a.gitkeepholding a note keeps each in the npm tarball, which drops empty directories; same trick as Reanimated's rootinclude/.gitkeep).package.jsonfilesmust re-list both.gitkeeppaths after its!**/.*rule, or npm drops them and SwiftPM resolution fails — check withnpm pack --dry-run --ignore-scripts | grep ios/spm. Both are required, tested 2026-10-19: with the defaultincludemissing (targets usepath: "."), resolution fails with "public headers ("include") directory path for 'RNAudioAPIDSP' is invalid"; one shared directory resolves but compiling fails with "umbrella for module 'RNAudioAPIDSP' already covers this directory", because each target gets its own umbrella module map. Pointing it atcommon/cppwould build an umbrella module over every C++ header; revisit when react-native-audio-worklets needs our headers under SwiftPM.package.jsonfilesnegates every download directory (external/xcframeworks,external/android,external/include_ffmpeg), so publishing from a machine with binaries downloaded still ships only the trackedexternal/includeheaders. Add a negation for any new download directory; check withnpm pack --dry-run --ignore-scripts.Context.packageDirectoryis the autolinking symlink (<app>/ios/build/generated/autolinking/libs/ReactNativeAudioApi, probed with afatalErrorduringxcodebuild -resolvePackageDependencieson 2026-10-19), not the resolvednode_modulespath.readAppConfiguration()therefore walkslibs → … → ios → <app>and finds the app even when the package is hoisted in a monorepo; it never passes the library's ownpackage.json. This relies on RN's symlink layout — re-probe if a future RN version references libraries by real path.- SwiftPM's manifest cache ignores files the manifest reads.
~/Library/Caches/org.swift.swiftpm/manifests/manifest.dbis keyed byPackage.swiftcontents + path + tools version + env + SwiftPM version (SwiftPMManifestLoader.CacheKey), so a changedpackage.jsonsection is invisible untilrm -rf ~/Library/Caches/org.swift.swiftpm/manifests(Xcode ▸ File ▸ Packages ▸ Reset Package Caches) — verified 2026-10-19: an identical manifest kept FFmpeg on after the option flipped off; appending a comment to the manifest made it re-evaluate. When testing option changes, bust the cache or change the manifest text; a fresh DerivedData is not enough. - Never replace a published asset in place. SwiftPM remembers each binary target's checksum per URL and refuses a changed artifact ("has changed checksum; this is a potential security risk"), so anyone who already resolved the tag breaks. Repacking always changes checksums (zip timestamps) — publish under a new tag instead.
- To test unpublished assets, rewrite a packed copy's binary targets to
binaryTarget(path: "<dir>/X.xcframework.zip")(local zips work) and install it withnpm install --ignore-scripts(a directory dependency otherwise runsprepare). - react-native-audio-worklets has its own
Package.swift(package/productReactNativeAudioWorklets, the name 0.87 derives;swiftpmConfigrepeats it and listsreact-native-audio-api/react-native-workletsasdependencies). It depends on the sibling autolinked packages../ReactNativeAudioApiand../RNWorklets(worklets names itselfRNWorkletsvia thespmblock in itsreact-native.config.js; Package.swift since worklets 0.13.0). Our RNAudioAPI target exposes no headers, so the worklets target reaches<audioapi/...>with.unsafeFlags(["-I", "<packageDirectory>/../ReactNativeAudioApi/common/cpp"])— the SwiftPM counterpart of the podspec'sHeaders/Public/RNAudioAPIpath (headerSearchPathcannot leave the package). It must defineDEBUG/NDEBUGper configuration like RNAudioAPI, for the same reason: React Native's headers change class layouts onNDEBUG. (Our own headers only useNDEBUGinside inline function bodies, e.g.BaseAudioContext::assertDriverMutexHeld, which changes behaviour, not layout.) Verified 2026-10-19: Debug + Release on 0.88.0, Release on 0.87.1, and at runtime on the iOS 27 simulator (NativeAudioWorkletsModuleresolves,install()returns true, AudioContext running). - Verify in throwaway apps on the oldest (0.87.x) and newest supported RN:
@react-native-community/cli init … --version <exact x.y.z>(a bare0.87finds no template), install annpm pack --ignore-scriptstarball under a unique file name,cd ios && npx react-native spm --deintegrate --yes(both versions pickadd/updatethemselves), thenxcodebuild -project <App>.xcodeproj.
Building the Apps
iOS (fabric-example)
# From the monorepo root first:
pnpm install
# Then install pods — must be done from the ios/ directory:
cd apps/fabric-example/ios
pod install
# Run the app (from repo root):
pnpm --filter fabric-example ios
# or open Xcode:
open apps/fabric-example/ios/FabricExample.xcworkspaceWhen to re-run pod install:
- After
pnpm install(any dependency change) - After changing
RNAudioAPI.podspec - After adding/removing iOS source files that need to be picked up
- After changing
rnaa_utils.rb - When prebuilt binaries need to be re-downloaded (podspec
prepare_commandruns onpod install)
Enable FFmpeg (off by default; apps/fabric-example/package.json enables it for every build path):
"react-native-audio-api": { "enableFFmpeg": true }Android (fabric-example)
pnpm --filter fabric-example android
# or open in Android Studio:
open apps/fabric-example/androidClean CMake cache (fixes most mysterious native build failures):
pnpm --filter react-native-audio-api clean # or manually:
rm -rf packages/react-native-audio-api/android/.cxxLocal Full Validation
CI builds the example app for Android and iOS only when native code changes (native-build.yml). Use the tiered local validation script for pre-PR checks:
pnpm validate:fast # CI parity: library + worklets `check` and `test` (affected C++ suites)
pnpm validate:cpp # C++ smoke
pnpm validate:cpp-extended # C++ extended (all categories)
pnpm validate:android # pnpm workspace … build:android
pnpm validate:ios # pnpm workspace … build:ios (macOS only)
pnpm validate:full # --fast with every C++ suite + --android + --iosScript: scripts/validate.sh at monorepo root.
What CI covers vs what validation tiers add
| Layer | CI (ci.yml) | Local tiers |
TS build (bob build) | Yes | --fast |
C++ smoke (run-tests.sh) | When common/cpp/, the lockfile or the library manifest changes (affected) | --fast (same rule), --cpp |
C++ coverage (run-coverage.sh, smoke, Clang) | Pull requests where smoke is selected (cpp-coverage.yml; PR comment with totals + changed-line coverage) | pnpm test:cpp:coverage |
| Jest | Yes | --fast |
| Extended C++ by category (e.g. graph) | When the category's paths change (affected) | --fast (same rule), --cpp-extended |
HostObjects (26 JSI .cpp files) | No | --android + --ios |
| Android JNI C++ + Kotlin | No | --android |
| iOS ObjC++ | No | --ios |
| Prebuilt libs (Opus, FFmpeg, etc.) | No | --android / --ios (via download-prebuilt-binaries.sh) |
| TurboModule codegen, worklets linking | No | --android / --ios |
The C++ test build excludes HostObjects, the platform audio players, FfmpegDecoder.cpp, and worklet nodes — see C++ Tests below. Passing pnpm test alone does not prove native layers compile.
Shared prebuild phase (before native tiers)
Before --android or --ios, the script runs once:
pnpm install --frozen-lockfile+pnpm builddownload-prebuilt-binaries.sh{android|ios}(must run frompackages/react-native-audio-api/scripts/)pnpm --filter react-native-audio-api test:cpp
Android (NDK) and iOS (Clang) cannot share object files — reuse is at the prebuild/download level. If ccache is installed, validate.sh wraps host CC/CXX; only the host C++ tests (test:cpp) honor that — Gradle/NDK and xcodebuild use their own toolchains and are unaffected.
Platform skip behavior
--ioson Linux → skip with message (exit 0)--androidwithoutANDROID_HOME→ fail on explicit--android; skip with warning inside--full--fullruns--fastwithTEST_ALL=1, so every C++ suite runs, then the native builds
Which tier to run
See the decision table in post-work-checks.
C++ Tests (standalone build)
Location
packages/react-native-audio-api/common/cpp/test/
How to run
pnpm test # Jest + the C++ suites your changes touch
pnpm --filter react-native-audio-api test:cpp:smoke|extended|full|affected
pnpm --filter react-native-audio-api test:cpp:extended -- graphrun-tests.sh [smoke|extended|full|affected] [category…] [--ubasan|--tsan|--no-ubasan] uses filters from filters.sh. affected picks suites by matching changed files against cpp_test_paths_for_suite. Docs: common/cpp/test/TESTING.md. Shell scripts in this repo use kebab-case plus .sh (run-tests.sh, not RunTests.sh).
Sanitizer binaries compile every engine translation unit with that sanitizer.
add_sanitized_tests(<name> <compile-flags> <link-flags>)buildstests_<name>plusrnaudioapi_<name>andrnaudioapi_libs_<name>.tsanuses-fsanitize=thread;asanuses-fsanitize=address,undefined. The plainrnaudioapipair is only fortestsand the coverage build. TSan misses release/acquire pairs in uninstrumented code, so an uninstrumented engine turns every SPSC hand-off into a false race (<null>frames, "As if synchronized via sleep"). ASan and UBSan simply never check a translation unit they did not compile.AudioThreadGuard.cppis compiled into the executable, not the static lib, so its__SANITIZE_*macros match that binary. GoogleTest stays the shared uninstrumented target: one gtest cannot be compiled with both sanitizers and with neither.
Coverage (Clang / llvm-cov)
pnpm --filter react-native-audio-api test:cpp:coverage
# open packages/react-native-audio-api/common/cpp/test/coverage-html/index.htmlrun-coverage.sh configures a separate build-coverage/ tree with -DENABLE_COVERAGE=ON (Clang-only LLVM source-based coverage: -fprofile-instr-generate -fcoverage-mapping), defaults CC/CXX to clang/clang++ when unset, runs the smoke filter from filters.sh, then prints llvm-cov report and writes HTML via llvm-cov show -format=html. When GITHUB_STEP_SUMMARY is set, the report is also appended there. It also writes build-coverage/coverage.lcov and build-coverage/coverage-totals.md (line/function/region totals, via llvm-cov export --summary-only + jq). Sanitizer targets are skipped when coverage is enabled. Requires Apple Clang / xcrun llvm-profdata and xcrun llvm-cov on macOS (or the same tools on PATH for Linux). On macOS with Homebrew LLVM first on PATH, clang is Homebrew's while the profile tools come from xcrun, and llvm-profdata merge fails with "raw profile version mismatch": run with CC=/usr/bin/clang CXX=/usr/bin/clang++ after deleting build-coverage/ (CMake caches the compiler).
coverage-pr-report.sh <output.md> turns those files into the PR comment: totals, then diff-cover's coverage of the lines changed since cpp_test_base_ref (no coverage data from the base is needed), with the uncovered snippets collapsed and dropped when the comment would exceed GitHub's size limit.
ci.yml calls cpp-coverage.yml on pull requests that change the library. Its affected job runs cpp_test_affected_suites (the same selection as the library's test; test-all from the shared filter) and its coverage job runs only when smoke is selected (setup-env tools cmake, llvm, diff-cover). The report goes up through .github/actions/upload-pr-report, and pr-report-comment.yml posts it. Smoke in the library's test keeps its own plain build.
Generated build trees must be named
build*. The C++ linters walk the filesystem withfindand never consult git, so a.gitignoreentry does not keep generated sources out of them. Exclusion happens by directory name in two places that must stay in sync:**/build*/**in.clang-format-ignore(used byformat:check:common) and-type d -name 'build*' -pruneinscripts/cpplint.sh. A CMake binary directory outside that prefix makes the pre-commit hook fail on generated files such asCMakeFiles/*/CompilerIdCXX/CMakeCXXCompilerId.cpp. CI never hits this because it checks out a clean tree.
Key design decisions
- Completely standalone — no Gradle, no Xcode, no prebuilt Android libraries needed
- Sources compiled from the package directory itself; react-native headers from the package's own
node_modules/react-native - HostObjects (except the
list(APPEND RNAUDIOAPI_SRC …)exceptions), AudioContext, and FfmpegDecoder are excluded from the test build. There is no worklets-node filter and noRN_AUDIO_API_ENABLE_WORKLETSdefine; engine sources no longer read that flag - The static lib compiles
jsi/jsi.cpp, so real JSI types (jsi::HostObject,jsi::MutableBuffer) work in tests. When core code a test links constructs a HostObject (e.g.AudioRecorderCallback→AudioBufferHostObject), add that HostObject's.cppto thelist(APPEND RNAUDIOAPI_SRC …)exceptions intest/CMakeLists.txt(as forJsEnumParser.cppandAudioBufferHostObject.cpp) instead of writing a stub translation unit or an#if RN_AUDIO_API_TESTtest double - Compile definitions:
RN_AUDIO_API_TEST=1,RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED=1,MA_NO_LIBOPUS=1,MA_NO_LIBVORBIS=1(FFmpeg is off because its define is absent).add_compile_definitionsis directory-scoped, so every target in this file receives them - Google Test auto-fetched via
FetchContentif not installed locally - The test build does not build libopus or libogg, so the bundled Ogg/Opus encoder (
encoding/OggOpusEncoder.cpp) and the Ogg/Opus concat remux (encoding/OggOpusRemux.cpp) compile to nothing there and have no desktop tests. They are guarded directly by!RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED(no separate availability macro), which the test build sets for every target. With the libs disabled, iOS losesOpusOggand Android falls back to itsAMediaMuxerOgg path (API 34+ at runtime);EncoderCapabilities.handAndroidEncoder.cppcarry both branches. The repo prebuilts cannot be linked on the desktop anyway: the legacyexternal/macosx/*.aare Mac Catalyst slices and the xcframeworks carry no plain macOS slice - Engine code includes the vendored codec headers by repo path (
<audioapi/external/include/opus/opus.h>,<audioapi/external/include/ogg/ogg.h>); libogg's headers include each other as<ogg/...>, socommon/cpp/audioapi/external/includemust be on the include path of every build (it is on Android, CocoaPods, SwiftPM and the test build) - New test files in
test/src/**/*.cppare picked up automatically by glob — no CMakeLists edit needed jsi.cppis compiled into the static lib so library members that reference JSI symbols (e.g.AudioFileProperties::CreateFromJSIValue) link when a test first pulls them in; a static-lib member costs nothing unless demanded. If a new test triggersUndefined symbols: facebook::jsi::..., the referenced runtime source is missing from the lib — add it there rather than stubbing the symbol
For MockAudioEventHandlerRegistry, TestableXxx pattern, and full CMakeLists analysis see build-details.md.
WPT Node bindings build (wpt_tests/CMakeLists.txt)
Builds the C++ engine as a Node.js addon (.node, via cmake-js + microsoft/node-api-jsi) so Web Platform Tests can run against it: pnpm --filter react-native-audio-api node:build (part of pnpm wpt). The engine is always compiled from the workspace common/cpp sources.
The JS wrapper layer (lib/commonjs classes and error types) is resolved by wpt_tests/package-root.js. By default it uses the workspace build output of pnpm build; set RN_AUDIO_API_APP_ROOT to an app directory to load the react-native-audio-api JS installed for that app instead (e.g. a published npm release):
RN_AUDIO_API_APP_ROOT=/path/to/app pnpm wpt:onlyClasses missing from an older package version are skipped with a warning, so their tests fail at runtime instead of crashing the harness at load. Note the native addon is NOT swapped by this env var — only the JS layer.
Resolution pitfalls learned the hard way (both handled inside package-root.js):
- The app's copy must be resolved with Node resolution from the app directory, not a hard-coded
<app>/node_modules/<pkg>path: package managers that hoist may place it in an ancestornode_modules. require.resolve('react-native-audio-api/...', { paths: [appRoot] })from a file inside the workspace package still resolves to the workspace itself (Node package self-reference beats thepathsoption). UsecreateRequire(path.join(appRoot, 'anything.js'))to anchor resolution in the app.
pnpm wpt:report:docs runs the suite twice (workspace main, then the stable release pinned in apps/common-app via wpt:report:stable) and regenerates the side-by-side table in packages/audiodocs/docs/other/web-audio-api-coverage.mdx.
Conditional Compilation Flags Summary
| Flag | Android (CMake) | iOS (podspec) | Tests | |
RN_AUDIO_API_FFMPEG_ENABLED | -DRN_AUDIO_API_FFMPEG_ENABLED=1 (only with enableFFmpeg: true in the app's package.json) | same | Not set (off) | |
RN_AUDIO_API_ENABLE_WORKLETS | Not set (engine no longer reads it) | Not set | Not set. wpt_tests/CMakeLists.txt still passes =0 | |
RCT_NEW_ARCH_ENABLED | -DRCT_NEW_ARCH_ENABLED | -DRCT_NEW_ARCH_ENABLED | Not set | |
HAVE_ARM_NEON_INTRINSICS | Set by CMake SIMD detection | Set by Xcode/Clang for arm64 | Set by CMake SIMD detection | |
HAVE_X86_SSE2 | Set by CMake SIMD detection | Not used | Set by CMake SIMD detection | |
HAVE_ACCELERATE | Not set | GCC_PREPROCESSOR_DEFINITIONS | Not set | |
RN_AUDIO_API_TEST | Not set | Not set | Always set to 1 |
OS-API selector headers (decoding/OSDecoding.h, encoding/OSEncoding.h, encoding/OSRemux.h, encoding/OSFilePath.h): common code reaches platform implementations through #if defined(__ANDROID__) / #elif defined(__APPLE__) && !defined(RN_AUDIO_API_TEST) && !defined(RN_AUDIO_API_NODE) dispatch. The Apple branch must exclude both desktop defines: the gtest build (RN_AUDIO_API_TEST) and the WPT node addon (RN_AUDIO_API_NODE) run on macOS (where __APPLE__ is defined) but do not compile or link the ios/ ObjC++ sources. The node build cannot borrow RN_AUDIO_API_TEST instead — that flag also switches on gtest-only code (gtest_prod.h includes, test ArrayBuffer shims). When adding a new OS-selector header, copy the full three-clause guard; an incremental wpt_tests/build dir can mask a missing clause for a long time, so verify with a clean pnpm node:build. Platform glue selected this way lives in android/src/main/cpp/audioapi/android/ (e.g. AndroidDecoding, AndroidEncoder, AndroidRemux) and ios/audioapi/ios/core/utils/ (e.g. IOSDecoding, IOSEncoder, IOSRemux) — both picked up automatically by the CMake glob / podspec glob, no build-file edits needed. A selector header only names the platform type; choosing between it and a bundled or optional library (FFmpeg, the Ogg/Opus encoder) belongs in the factory (decoding/DecoderFactory.cpp, encoding/EncoderFactory.cpp), which holds that library's flag check in one place.
Common Build Failure Patterns
| Symptom | Likely cause | Fix |
file not found: libopus.a | Prebuilt binaries not downloaded | Run pod install (iOS) or Gradle build (triggers download task) |
Download failed for …/rn-audio-libs/… after 3 attempts with the network fine | Two download runs at once in one package folder (iOS and Android built together) | Rerun the build; build one platform at a time (see Prebuilt Binaries) |
No such module 'RNAudioAPI' | Pod not installed | cd apps/fabric-example/ios && pod install |
undefined symbol: av_* | FFmpeg .so not in jniLibs | Build triggers download; verify "enableFFmpeg": true is in the app's package.json (FFmpeg is off by default) |
'libavcodec/avcodec.h' file not found | FFmpeg include dir is gated on the enable flag; something compiled FfmpegDecoder.cpp in a disabled build | Check the source filter (list(FILTER … FfmpegDecoder\.cpp$) / podspec exclude_files) picked the file up |
| CMake error on clean build | Stale .cxx cache | rm -rf packages/react-native-audio-api/android/.cxx |
Test build: Cannot open include file: audioapi/... | Node modules not linked | pnpm install from root, then re-run tests |
New .cpp not compiled in tests | Glob picks it up automatically — may need cmake reconfigure | Delete test/build/ and re-run |
iOS compile error unknown type 'id' | C++ file included ObjC-only header | Compile that file as ObjC++ (separate subspec with -x objective-c++) |
RCT_NEW_ARCH_ENABLED undefined on Android | App sets newArchEnabled=false | Remove it; a missing property already means the New Architecture |
iOS: 'to_chars' is unavailable: introduced in iOS 16.3 from formatter_floating_point.h, instantiated by std::format<...> | std::format in code compiled for iOS. libc++ availability-gates the whole <format> library to iOS 16.3; the podspec minimum is ios_min_version = '14.0'. The desktop C++ test build and Android NDK have no such gate, so pnpm test:cpp passes and only the iOS build fails. | Use std::string concatenation / std::to_string in common/cpp and ios/. Zero-pad by hand (insert(0, n, '0')). Android-only files (android/src/main/cpp) may keep std::format. |
iOS test target: Undefined symbol: audioapi::<something> for a function that exists in common/cpp and compiles in the pod | The XCTest bundle links against the host app, and the host app only pulls the static-lib members its own code references. A common symbol nobody in ios/ or the HostObjects uses never reaches the host. | Compute it inline in the test, or make the library reference it; do not add a fake use in production code. |
iOS: new common/cpp .cpp not compiled at all (Undefined symbol with no CompileC line for it) | CocoaPods expands source_files globs at pod install, not at build time | cd apps/fabric-example/ios && pod install after adding a source file |
Android/iOS: after editing a C++/TS mirrored enum (FileFormat, BitDepth, …) the app silently uses the wrong value (e.g. records FLAC when JS asked for ADTS) | Metro hot-reloaded the TS enum with the new numbering, but the installed binary still carries the old C++ numbering; enum values cross JSI as plain numbers | Reinstall the app (installDebug / run-ios) after any enum reorder; a JS reload is never enough |
Android incremental build only: Unresolved reference to a top-level Kotlin function, or Cannot access '…': it is internal in file, while --rerun-tasks passes | Incremental Kotlin rounds treat the module's own earlier classes as a foreign module (library is built through the node_modules/react-native-audio-api symlink) | Use only public classes/objects across files in android/src/main/java; no top-level functions, no internal |
clangd only: 'React/RCTBridgeModule.h' file not found in .mm files | compile_commands.json has no framework search path | See clangd compile database below — regenerate with pnpm setup:clangd |
clangd compile database
packages/react-native-audio-api/common/cpp/clangd/ generates the repo-root
compile_commands.json that clangd reads (pnpm setup:clangd, or
pnpm setup:clangd:clean after a native dependency bump). It is editor tooling
only — it never participates in a real build. See its SETUP.md.
The iOS half reuses whatever pod install resolved for apps/fabric-example,
reading both HEADER_SEARCH_PATHS and FRAMEWORK_SEARCH_PATHS out of
Pods/Target Support Files/Pods-FabricExample/Pods-FabricExample.debug.xcconfig.
Framework search paths matter because React-Core ships prebuilt as
React.xcframework since RN 0.87: #import <React/RCTBridgeModule.h> resolves
via -F, not -I, so an -I-only database fails every .mm that imports
React. Xcode's own -F points at PODS_XCFRAMEWORKS_BUILD_DIR, which only
exists after Xcode has unpacked the slices — the CMakeLists globs the
ios-*simulator* slices inside the .xcframework bundles instead, so a bare
pod install suffices.
To check the database rather than guessing at clangd, replay an entry directly:
python3 -c "
import json,shlex,subprocess
e=[x for x in json.load(open('compile_commands.json')) if x['file'].endswith('ios/AudioAPIModule.mm')][0]
toks=[t for t in shlex.split(e['command']) if t!='-c']
subprocess.run(toks[:toks.index('-o')]+toks[toks.index('-o')+2:]+['-fsyntax-only'], cwd=e['directory'])
"If that reproduces the error, the database is wrong — not the editor's LSP setup.
Maintenance: see maintenance.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

