microsoft/rnx-kit

react-native-host - fails to build when used in conjunction with use_frameworks (static) on new architecture

garvsgit opened this issue ยท 6 comments

What happened?

@tido64
I'm unable to use react-native-host in my app when I build with statically linked frameworks. The issue is probably related to header search paths not being updated properly for React-RCTFabric pod as mentioned in reactwg/react-native-new-architecture#115.

The exact build error is react/utils/ContextContainer.h file not found in RCTSurfacePresenterBridgeAdapter.h.
Can you please look into enabling use_frameworks support for new architecture

Affected Package

@rnx-kit/react-native-host

Version

0.4.5

Which platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows

System Information

Node: 20.11.0
react-native: 0.72.7
hermesEnabled: true
newArchEnabled: true

Steps to Reproduce

Create a template app from react native cli
npx react-native@0.72.7 init react-native-host-demo --version 0.72.7
Install react-native-host using npm
npm add --save-dev @rnx-kit/react-native-host

Edit the podfile to use statically linked frameworks and disable flipper
linkage = 'static'
Disable flipper inside use_react_native!
Do pod install
RCT_NEW_ARCH_ENABLED=1 bundle exec pod install

Buildreact-native-host-demo.xcworkspace inside Xcode

Issue -> Header files not found inside React-RCTFabric pod

Code of Conduct

  • I agree to follow this project's Code of Conduct

hey @garvsgit - a quick question, is the issue still present if you update to latest 0.72? https://github.com/facebook/react-native/releases/tag/v0.72.12

Thanks for checking in @kelset.
Yes, I can confirm that the issue is still present in latest 0.72.12
The repro steps are same as 0.72.7

@garvsgit, would you mind testing the changes in the PR ๐Ÿ‘† locally?

Hey @tido64,
I just got around to testing this. So the build issue is fixed. However, the app gives a looping runtime error of Unable to find module for redbox and never loads the react root view.

Update - It's fixed. There was an issue in the initialization of React Native Host in my implementation. Thanks @tido64 for the prompt fix.

PS - Should probably highlight this in the documentation that we need to retain a reference to ReactNativeHost. The code example in the documentation causes deallocation after the method returns (https://github.com/microsoft/rnx-kit/blob/main/packages/react-native-host/README.md)

PS - Should probably highlight this in the documentation that we need to retain a reference to ReactNativeHost. The code example in the documentation causes deallocation after the method returns (https://github.com/microsoft/rnx-kit/blob/main/packages/react-native-host/README.md)

That's a good point. Updated the example here: #3036