'File not found' when integrating React Native with existing project - ios

I'm having problems integrating React Native into my existing iOS project. When I run the project through Xcode, everything works as expected. However, when I run the project with through the terminal (using command: npx react-native run-ios), I get an error as follows:
fatal error: 'React/RCTRootView.h' file not found
#import <React/RCTRootView.h>
It's not just RCTRootView though, it's all react native imports. The setup is done with npm and cocoapods. If I remove all the import statements in the code, I instead get this error:
framework not found CoreModules
Steps I've taken:
I followed the steps on https://reactnative.dev/docs/integration-with-existing-apps to the letter
I searched for a long time on similar issues on SO and on the React Native GitHub issues page; none of the suggested solutions work.
The fact that it all works when running through Xcode was quite confusing. I run the same configuration and scheme when running through npx.

I found the answer halfway through writing the question, so I thought I might as well post it in case it might save someone some time in the future. It took me a while because the initial error I got wasn't the core problem.
The issue was caused by the fact that I'd forgotten to update the deployment target in the target deployment info (from iOS 9 to iOS 11).
Also some cred to where I found the solution:
https://github.com/facebook/react-native/issues/26106#issuecomment-600328194

Related

'react/bridging/CallbackWrapper.h' file not found in React Native

I am trying to setup my React Native app on iOS, but on build, I am always getting this error:
'react/bridging/CallbackWrapper.h' file not found
I have been investigating on my own and found a few people with the same problem:
https://github.com/mrousavy/react-native-vision-camera/issues/1121
https://github.com/facebook/react-native/issues/34102
I have tried everything in these answers but no luck. Since it seems related to React Native Vision Camera, I also did everything stated in their troubleshooting page.
Unforrunately I still get the error. I built the project both using npx react-native run-ios (which throws an endless error) and using XCode itself, where I could find the real error.
Can you help me? The app works perfectly in Android. Thanks!
If nothing of the links I pasted in the question work, what finally worked for me was:
Updgrade React Native to >= 0.69.3 (my version was 0.69.0). To do that npx react-native upgrade.
Delete Pods folder and Podfile.lock from iOS folder. Run pod install.
And then building the project again.
The way to fix the problem is to comment-out the line :
s.header_dir = "react/bridging"
in
/node_modules/react-native/ReactCommon/React-bridging.podspec

UMModuleRegistryAdapter.h not found when running React Native app in iOS simulator

I have a simple React Native app that I've been testing on Android and now want to test on iOS. It's using React Navigation.
I ran npm run ios but I'm getting the following error:
info In file included from
/Users/rbbit/reactnative/testproj1/ios/testproj1/main.m:10:
/Users/rbbit/reactnative/testproj1/ios/testproj1/AppDelegate.h:9:9: fatal error: 'UMReactNativeAdapter/UMModuleRegistryAdapter.h' file not found
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
info 1 error generated.
I opened XCode but I'm basically getting the same message, nothing else that would help me debug this.
I do see that there is a package called react-native-adapter (https://github.com/expo/expo/tree/master/packages/%40unimodules/react-native-adapter), however I'm hesitant to just install this since I followed the instructions on how to include react-navigation and didn't mention that, assuming this is related.
Also, that page says If you are using react-native-unimodules, this package will already be installed and configured!, and react-native-unimodules already is in my dependencies.
Any pointers on how to solve this? Thank you!
For latest RN versions (RN 0.60+) errors like this should be fixed with the auto-linking and just running a pod install.
For older versions you should try:
react-native link in the root folder of your project
Then in Xcode Product->Clean Build folder, restart JS server and attempt to rebuild.
If still not working double check the configs from here:
https://github.com/unimodules/react-native-unimodules
and the App.delegate from here:
https://gist.github.com/brentvatne/1ece8c32a3c5c9d0ac3a470460c65603
Sources:
Pod install reminder was first suggested by Sandy in the below comment
pod install didn't work for me until I added these lines to my pod file:
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
And
use_unimodules!(modules_paths: ['../node_modules'])
Then do a pod install.
Example: https://gist.github.com/sjchmiela/6c079f2173938a9a61a7c6f053c45000
I had this exact same error with everything configured correctly, everything in the other answers done and all the unimodules installation steps already done, on a project that had worked for months, building it on a new computer. It turned out the reason was because I was simply using the wrong file in xCode.
I had opened the .xcodeproj file when I should have opened and run the build from the .xcworkspace file.
Everything seemed to work as normal apart from this error, which made it look like a configuration problem rather than a simple "you opened the wrong file" problem. Hopefully if someone else makes the same mistake, this will save them a few hours of fruitless tinkering.

Error message - RNFirebase core module was not found natively on iOS

React Native Firebase won’t install on iOS React Native project. It works fine on Android.
I followed this instruction.
https://rnfirebase.io/docs/v5.x.x/installation/initial-setup
I set up Firebase, added the downloaded plist file via XCode, installed and set up Cocoapod.
The moment I add the following line to my App.js, the simulator returns an error message.
import firebase from 'react-native-firebase';
The error message: “RNFirebase core module was not found natively on iOS”
I’ve tried a few things I picked up from this forum:
https://github.com/invertase/react-native-firebase/issues/614
I commented out following lines from Podfile
use_frameworks!
And then pod install, pod update
on Xcode, checked the Build Phases/ Link Binary with Libraries section. I checked libRNFirebase.a was already there.
I've been trying this for a few months now on and off. And I haven't found a way to make React Native Firebase install on iOS project. Any pointer would be much appreciated.
I'm currently maintaining the react-native-firebase v5 branch (current stable) and we do have a problem with the header search paths right now for some reason.
I don't have a definitive fix, but I constructed a demo that goes from react-native init, then installs react-native-firebase, and does all the things necessary such that the project builds and runs on iOS and even archives in release mode.
You may see it here: https://github.com/mikehardy/rnfbdemo
The only thing that is important at the moment is that you need to put one non-documented thing in your Podfile after following all the install instructions, as the last line before the final end
system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/")

RN 0.38.0 React/RCTBridgeModule.h' file not found

This is a long shot, but I've taken over a project done in RN v .38 and I need to update a library and resolve the build issues without updating the version of react native. I'm trying to update the react-native-aws-cognito-js library and while it looks to be compatible with the formatting change of import statements, I'm still not able to get it to build on IOS. Android is fine.
To reproduce my issue I did the following:
react-native init sample --version 0.38.0
cd sample
npm install react-native-aws-cognito-js
react-native link react-native-aws-cognito-js
react-native run-ios
Which fails with:
/node_modules/react-native-aws-cognito-js/ios/RNAWSCognito.h:4:9:
fatal error: 'React/RCTBridgeModule.h' file not found #import
Mobile and RN development is not my wheelhouse, but I'm hoping there is some sort of xcode configuration or tricks I can do to get this working and avoid a major overhaul. Running an upgrade to >.40 would probably take too long and also cause other compatibility issues that I don't have the time to resolve.
Note: I have tried the suggestions in `React/RCTBridgeModule.h` file not found

React Native - Linked NativeModule works when run from Xcode, but not from packager

I recently added bugsnag-react-native and followed the directions for linking. When I run using the packager without Xcode, I get the following error screen.
When I search on Google for answers, the only relevant issue posted is Runtime Error: No Native client found which suggests that its a linking problem and to follow the directions, but from my perspective everything looks fine and I followed the direction.
What reason would a native module only be available when run from Xcode?
I had a similar issue and below solved it:
If you can successfully run from Xcode, then delete your ios/build folder (rm -rf ios/build) and re-run react-native run-ios.

Resources