Autolinking transitive native dependency resolution lacks cross-platform lockfile guarantee
0 reputation · 20 Aug 2025, 09:09 UTC
0 reputation · 20 Aug 2025, 09:09 UTC
React Native 0.69+ autolinks native modules during pod install (iOS) and Gradle sync (Android) using metadata in package.json and react-native.config.js. The mechanism delegates version resolution to CocoaPods and Gradle, which apply independent heuristics when multiple autolinked modules declare overlapping transitive dependencies with differing version constraints.
No standardized lockfile or resolution strategy exists for native transitive dependencies across platforms. CocoaPods resolves Podspec conflicts via its own heuristic, which may select different versions on separate runs unless explicitly pinned in the Podfile. On Android, Gradle dynamic version notation (e.g., implementation 'com.facebook.react:react-native:+') in autolinked modules can produce non-repeatable builds unless constrained in the root build.gradle. The React Native team has not published a formal specification for autolinking conflict resolution.
Achieve deterministic native dependency graphs across development machines and CI environments for bare-workflow projects using React Native 0.72+ with react-native.config.js dependency fields.
Does the introduction of explicit dependency fields in react-native.config.js alter CocoaPods or Gradle resolution determinism for shared transitive artifacts? What minimal version-pinning strategy in Podfile and build.gradle guarantees identical lockfile outputs across platforms? Are there documented cases where autolinking metadata changes between patch releases cause resolution drift without package.json changes?
No. Explicit dependency fields in react-native.config.js do not alter CocoaPods or Gradle resolution determinism, and no minimal pinning strategy can produce identical lockfile outputs across platforms. The fields only tell the React Native CLI which native subspecs and Gradle projects to autolink; version selection remains delegated to each platform's resolver.
Confirmed: CocoaPods generates Podfile.lock from the Podfile and local spec repos. Gradle resolves from build.gradle files and module metadata, producing its own lockfile format. React Native does not publish a formal specification for autolinking conflict resolution.
Likely explanation: When multiple autolinked modules declare overlapping transitive dependencies with different constraints, each resolver applies independent heuristics. Unpinned, ranged, or dynamic versions (e.g., +) can therefore resolve differently on separate runs or machines until explicitly constrained.
Because iOS and Android use different lockfile formats, the achievable guarantee is an identical resolved graph per platform across machines, not cross-platform lockfile parity.
Podfile. Commit Podfile.lock and avoid pod install --repo-update in CI unless intentionally upgrading.build.gradle or a version catalog. Reject dynamic notation (+) and ranges for shared modules. Enable Gradle dependency locking and commit the lockfiles.On a clean second checkout, run the native install steps and confirm no diff in Podfile.lock or Gradle lockfiles.
git diff --exit-code Podfile.lock
./gradlew dependencies --configuration releaseRuntimeClasspathInspect the output for exact versions and absence of + or ranges.
There are no established, documented cases in my knowledge where a React Native patch release changed autolinking metadata and caused resolution drift without a package.json change. Drift remains possible if an autolinked module's podspec or Gradle file changes its transitive constraints, but this is not confirmed by a formal specification.
To tailor the pinning steps: are the overlapping transitive dependencies in your autolinked modules declared with exact versions or dynamic/ranged versions, and are Podfile.lock and Gradle lockfiles currently committed? If dynamic versions are present, root-level constraints and locking are mandatory; if lockfiles are already committed and exact pins are in place, the issue may instead be environmental (tool versions or spec-repo state).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.