Skip to content

fix: Keep cxxreact out of public headers with RN_STRICT_API umbrellas - #2046

Open
huextrat wants to merge 1 commit into
margelo:mainfrom
huextrat:fix/react-native-core-cxxreact-modulemap
Open

huextrat wants to merge 1 commit into
margelo:mainfrom
huextrat:fix/react-native-core-cxxreact-modulemap

Conversation

@huextrat

@huextrat huextrat commented Nov 4, 2026 •

Copy link
Copy Markdown

Summary

Since 0.37.2, iOS builds with use_frameworks! on React Native <= 0.88 fail again with the same error as #1520:

❌ 'jserrorhandler/ErrorUtils.h' file not found   (react-native/ReactCommon/cxxreact/ErrorUtils.h:12)
❌ could not build module 'cxxreact'               (react-native-nitro-modules/cpp/views/ReactNativeCore.hpp:8)

#2025 moved the React Native version include into the new ReactNativeCore.hpp:

#if __has_include(<React/Utils.h>)
#include <React/Utils.h>
#else
#include <cxxreact/ReactNativeVersion.h>
#endif

On React Native <= 0.88 there is no <React/Utils.h> umbrella, so it falls back to <cxxreact/ReactNativeVersion.h>. ReactNativeCore.hpp is included by three public headers, so cxxreact ends up in the NitroModules modulemap again:

  • ReactProp.hpp > ReactNativeCore.hpp > cxxreact/ReactNativeVersion.h
  • ViewComponentDescriptor.hpp > ReactNativeCore.hpp > cxxreact/ReactNativeVersion.h
  • ViewPropsHolderState.hpp > ReactNativeCore.hpp > cxxreact/ReactNativeVersion.h

#1521 had fixed this by keeping the version include in RawPropsCompat.cpp.

Changes

  • ReactNativeCore.hpp only includes the renderer core headers (<React/RendererCore.h> or the react/renderer/core/* fallbacks), plus a comment explaining why the version header must stay out of it.
  • RawPropsCompat.cpp, the only place that uses REACT_NATIVE_VERSION_*, includes <React/Utils.h> or <cxxreact/ReactNativeVersion.h> itself, with the same __has_include check as fix: build under React Native 0.89's RN_STRICT_API #2025. RN 0.89 RN_STRICT_API builds keep using the umbrella.

Test plan

  • Walked the transitive includes of every header listed in public_header_files of NitroModules.podspec: three chains reach cxxreact on 0.37.2, none with this change. The react/renderer/core/* headers kept in ReactNativeCore.hpp don't reach cxxreact on RN 0.88.1.
  • clang-format with config/.clang-format: no changes.
  • Shipping the same change as a yarn patch on 0.37.2 in a production app (Expo SDK 58, RN 0.88.1 built from source, use_frameworks! :linkage => :dynamic), which is where the archive failure showed up. The iOS CI build with the patch is running.

Regression of #1520, introduced by #2025.

…llas

margelo#2025 moved the React Native version include into `ReactNativeCore.hpp`,
which is included by public headers (`ReactProp.hpp`,
`ViewComponentDescriptor.hpp`, `ViewPropsHolderState.hpp`). On React Native
<= 0.88 there is no `<React/Utils.h>` umbrella, so it falls back to
`<cxxreact/ReactNativeVersion.h>`, which puts `cxxreact` back into the
NitroModules modulemap and breaks `use_frameworks!` builds with
"could not build module 'cxxreact'" (regression of margelo#1520).

The `REACT_NATIVE_VERSION_*` macros are only used in `RawPropsCompat.cpp`,
so include the version header in that translation unit only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
nitro-docs Skipped Skipped Nov 4, 2026 10:49am UTC

Request Review

This branch was previously deployed

1 inactive deployment
Preview — 05b548d7 Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant