可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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: https://github.com/facebook/react-native/issues/11721#issuecomment-270672904).
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:
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: https://github.com/johanneslumpe/react-native-fs/pull/238/files
回答3:
Make sure you disable Parallelise Build
and add React
target above your target
回答4:
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.
回答5:
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
回答6:
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
回答7:
Change
#import "RCTBridgeModule.h"
to
#import "React/RCTBridgeModule.h"
回答8:
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.
回答9:
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.