问题
Getting this error while building a react-native iOS app on xcode.
Started getting this error after npm install and rpm linking react-native-fs library. But after searching online for a solution, I noticed that many people are getting the same error while installing other react native libraries.
A possible solution suggested by many is, Adding the following under "Build Settings" -> "Header Search Paths".
$(SRCROOT)/../node_modules/react-native/React
- (Recursive)
But no luck with this solution, still getting the same error
回答1:
In my case this particular problem happened when I was trying to archive a 0.40+ react-native app for iOS (solution was found here: Reliable build on ^0.39.2 fails when upgrading to ^0.40.0).
What happened was that Xcode was trying to build the react-native libraries in parallel and was building libraries with implicit react dependencies before actually building the react library.
The solution in my case was to:
Disable the parallel builds:
- Xcode menu -> Product -> Scheme -> Manage Shemes...
- Double click on your application
- Build tab -> uncheck Parallelize Build
Add react as a project dependecy
- Xcode Project Navigator -> drag React.xcodeproj from Libraries to root tree
- Build Phases Tab -> Target Dependencies -> + -> add React
回答2:
Make sure you disable Parallelise Build
and add React
target above your target
回答3:
QUICK FIX (not the best)
Change the import react-native header lines:
#import <React/RCTBridgeModule.h>
#import <React/RCTLog.h>
To:
#import "RCTBridgeModule.h"
#import "RCTLog.h"
Here is an example of changes I had to make for the library I was trying to use: Closes #46 - 'RCTBridgeModule.h' file not found.
回答4:
Change
#import "RCTBridgeModule.h"
to
#import "React/RCTBridgeModule.h"
回答5:
For viewers who got this error after upgrading React Native to 0.40+, you may need to run react-native upgrade
on the command line.
回答6:
I was able to build a debug, but I was unable to build an archive.
I solved this issue by dragging React.xcodeproj
found in /node_modules/react-native/React to my root directory in Xcode, then added React as a target dependancy in build phases > target dependencies.
回答7:
If Libraries/React.xcodeproj
are red in xcode then reinstall node_modules
rm -rf node_modules && yarn
My newly created project from react-native 0.46.3 was red :S I have npm 5.3.0 and yarn 0.24.5 when I did react-native init
回答8:
Latest releases of react-native libraries as explained in previous posts and here have breaking compatibility changes. If you do not plan to upgrade to react-native 0.40+ yet you can force install previous version of the library, for example with react-native-fs:
npm install --save -E react-native-fs@1.5.1
回答9:
This error appeared for me after I ran pod install
command for the new dependencies. Along with those, React had also been installed. Therefore probably Xcode was confused for path. I removed these lines from PodFile and error was gone. Please note that those removed from here were already linked in Xcode.
target 'app' do
pod 'GoogleMaps'
pod 'Firebase/Auth', '~> 6.3.0'
pod 'Firebase/Database', '~> 6.3.0'
# Removed four pods below and it worked.
pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
pod 'react-native-image-resizer', :path => '../node_modules/react-native-image-resizer'
pod 'RNFS', :path => '../node_modules/react-native-fs'
end
回答10:
Go to iOS folder in your project and install pod - $ pod install
If you are getting any error in installation of pod type command- $ xcode-select -p
Result should be - /Applications/Xcode.app/Contents/Developer
If the path is incorrect then open your iOS project in Xcode and go to: Xcode->preferences->command line tools-> select xcode
And again install the pod your issue will be fix.
Enjoy,
回答11:
If you want to make it from your editor also open SMobile.xcscheme
And change parallelizeBuildables = "NO"
回答12:
For me didn't work any from the above solutions and below it is what worked (I had already checked out Parallelize Build
and added React
)
1. Open XCode --> To Libraries add `$LibraryWhichDoesNotWork.xcodeproj$`
2. Then for your app in the `Build Phases` add to the `Link Binary with Libraries` the file `lib$LibraryWhichDoesNotWork$.a`
回答13:
I've encountered this issue while upgrading from 0.58.4 to new react-native version 0.60.4. Nothing from what i found on the internet helped me, but I managed to get it working:
Go to build settings, search for 'Header search paths', select the entry, press DELETE button.
I had these values overriden, and looks like they fell back to defaults after deletion. Also Cocoapods was complaining about it with messages in Terminal after pod install
:
[!] The `app [Release]` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-app/Pods-app.release.xcconfig'. This can lead to problems with the CocoaPods installation
回答14:
For me, this error occurred when I added a new scheme/target (app.staging) in the app and installed pods using pod install.
This issue is occurring due to pods are not shared for all targets. So I need to add newly added target (app.staging) inside the Podfile.
Here is my Podfile.
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'app' do
# Pods for app
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
target 'appTests' do
inherit! :search_paths
# Pods for testing
end
# Pods for staging app // important line below
target 'app.staging'
use_native_modules!
end
回答15:
What you can do to get it right is:
1) npm uninstall reat-native-fs
to uninstall library
2)npm unlink react-native-fs
to unlink the library
Now the library is successfully removed and now install the lib again in your project and this time link everything manually. Sometime automatic linking causes this error.
来源:https://stackoverflow.com/questions/41663002/react-rctbridgemodule-h-file-not-found