async-storage: fatal error: 'React/RCTBridgeModule.h' file not found
Current behavior
After adding Async Storage build fails with fatal error: 'React/RCTBridgeModule.h' file not found
.
info In file included from /Users/.../node_modules/@react-native-community/async-storage/ios/RNCAsyncStorage.m:8:
/Users/.../node_modules/@react-native-community/async-storage/ios/RNCAsyncStorage.h:8:9: fatal error: 'React/RCTBridgeModule.h' file not found
info #import <React/RCTBridgeModule.h>
^~~~~~~~~~~~~~~~~~~~~~~~~
info 1 error generated.
The following build commands failed:
CompileC /Users/.../ios/build/.../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNCAsyncStorage.build/Objects-normal/x86_64/RNCAsyncStorage.o /Users/.../node_modules/@react-native-community/async-storage/ios/RNCAsyncStorage.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Environment
- Async Storage version: ^1.3.3
- React-Native version: 0.59.5
- Platform tested: iOS
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 24
- Comments: 71 (20 by maintainers)
Closing this one down, as it looks like it’s fixed.
I found that this issue appears when you add
use_frameworks!
to your PodfileThis did the magic, https://www.youtube.com/watch?v=JnZS5MoYKCY You just need to add React in scheme.
Same issue after upgrading to RN 0.61.1
@Lucas-Geitner: Yes, if you manually linked React Native, but used CocoaPods for AsyncStorage, there is no way for us to know where the React headers are. You’ll need to go all in on either, or add the React header path in the project’s header search path.
@alex-mironov, @sintylapse, @anarkafkas (and others having the original issue): can you check in your
Podfile
whether the following lines exist:If it does, can you remove them, run
pod install
again, then re-build. I think what’s happening is that React gets removed from the Pods project. RNCAsyncStorage has a target dependency on React to ensure that its headers are installed. With it removed, Xcode will build RNCAsyncStorage at any time, most often before React does.For me using manual linking only, without using Cocoapods, helped - https://github.com/react-native-community/react-native-async-storage/blob/master/docs/Linking.md#project-linking
Hey everyone,
I’ve thought something broke recently, so I went ahead and created a project from scratch (using pods).
Here’s my
Podfile
:Maybe you forgot to include React in your build?
Also, like @sebwib said (thanks btw.), the issue you’re seeing could come from the
Parallelize Build
option selected, where modules are build simultaneously, when your project is dependant on React Native.Please check if it’s the case. You can check it in your Scheme options (CMD + ‘<’). SS:
thanks.
@codoffer - I hope that you set build system as ‘Legacy Build System’ in Workspace.
Any other ideas not mentioned above? I am having the problem in RN 0.62.2.
Getting Same Error on newly created project with PODS. In Version “react-native”: “0.61.5”, Any solution for this??
I had this issue when i updated from 58 -> 61.2.
I Fixed by deleting the contents of the
Libraries
folder in the xCode Project.Same problem with @kennym on several libs after upgrading from RN 0.60.5 to 0.61.1. The errors are:
Already reported to RN in this issue
FYI, I only used
use_native_modules!
, notuse_framework!
@LukePenkava Hi, I’ve followed your steps and I could recreate
65 error
.I’ve fixed it by adding missing deps. My
Podfile
:@vongohren There was no activity for some time, so I assumed it has been dealt with. Reopening then.
Have you checked the troubleshooting guide for Pods ?
@LukePenkava Can you link your
Podfile
?remove this line in podfile:
pod 'RNCAsyncStorage', :path => '.....
manual link carefully, also make sure that
React.xcodeproj
appears withRNCAsyncStorage.xcodeproj
build againThanks @RichardLindhout Sounds like a last resort indeed…
It also makes sense to me that such a problem can be solved:
#import <RCTBridgeModule.h>
the problem was gone, but: (1) this doesn’t sound like the way to go, since when somebody will clone the repo and runnpm i
the problem will reappear, and (2) when I changed the import statement I get a similar error in another file, for#import <yoga/Yoga.h>
.#import "../../ReactCommon/yoga/yoga/Yoga.h"
, and I am still getting an error.@devangelmotta I cannot see React Native in your
Podfile
. How do you link against React Native? Did you have a look at our troubleshooting guide? Specifically this point may help you:If you’ve manually linked React Native, but use CocoaPods for AsyncStorage, AsyncStorage will not be able to find React headers. You’ll need to set header search path, or also consume React Native via CocoaPods.
Link not working
@kennym You should not need to add this dep to your cocoapods. Please compare your cocoapods file to the react-native-example app. Also compare the use_frameworks option and use_native_modules option.
Pod install won’t work as we need to give path for respective ‘RNCAsyncStorage.podspec’ file in our project’s pod file.
Add
pod 'RNCAsyncStorage', :podspec => '../node_modules/@react-native-community/async-storage/RNCAsyncStorage.podspec'
to your pod file and everything will work. No need to do manual linking.Let me know if this works for anyone.
@Krizzu With what comment has it been fixed?
Currently experincing this myself when pod installing
The pod file
I just dont see any good solutions here? I checked parallized. Im coming from the same situation as @sagargondaliya. Upgrading 64 bit for android and facing to ue this package, which now fails for iOS
I had to manually link to get it to work. But im running a monorepo, maybe there are some strangeness then? And some libs are hoisted
The Problem is with the new React-native 0.59.x
I fixed it by adding React and Yoga references to the Pod file, to make sure CocoaPod gets React dependency from node_modules instead of creating a new directory and pulling from other repo.
I used this method and it worked properly
@Lucas-Geitner Does your app build without AsyncStorage? Also, I can’t see React Native in your
Podfile
. How do you link it?Found this thread while having this issue, but not with this actual repo. The problem was that I still had not selected a development team for my reactnative xcodeproj (both regular target and the tests-target). But that blocked all building, so the dependencies also didn’t build. When I selected a dev team, the build started working and this issue when away during the build.