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
Screenshot 2019-04-30 11 03 25

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 24
  • Comments: 71 (20 by maintainers)

Most upvoted comments

Closing this one down, as it looks like it’s fixed.

I found that this issue appears when you add use_frameworks! to your Podfile

This 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:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

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.

Hey everyone,

I’ve thought something broke recently, so I went ahead and created a project from scratch (using pods).

Here’s my Podfile:

target 'YOUR_PROJECT_NAME' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
  platform :ios, '9.0'


  node_modules_path = '../node_modules'

  pod 'yoga', path: "#{node_modules_path}/react-native/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: "#{node_modules_path}/react-native"

  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

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:

Screenshot 2019-05-03 at 14 09 17

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:

  • ‘React/UIView+React.h’ file not found
  • ‘React/RCTBridgemodule.h’ file not found …

Already reported to RN in this issue

FYI, I only used use_native_modules!, not use_framework!

@LukePenkava Hi, I’ve followed your steps and I could recreate 65 error.

I’ve fixed it by adding missing deps. My Podfile:

platform :ios, '9.0'

target 'async' do
  #use_frameworks!

  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'

  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'


    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == "React"
          target.remove_from_project
        end
      end
    end

end

@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 with RNCAsyncStorage.xcodeproj build again

Thanks @RichardLindhout Sounds like a last resort indeed…

  • I have a project that is working on android, using RN 0.59.9, but never tested on iOS.
  • I upgraded to RN 0.62.2 and fixed few issues in order to make it work on android.
  • Now I want to make it work on IOS.
  • Starting all over again means a lot of work, also for android.

It also makes sense to me that such a problem can be solved:

  • Doesn’t Xcode use a well defined search path to resolve import statements (isn’t this what the definition of build Settings -> Search path is supposed to define? Did I define it improperly?)
  • When I change the import statement to #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 run npm 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>.
  • I tried to change this import statement to the following: #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.

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

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
target 'DiwalaMobile' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  node_modules_path = '../node_modules'

  # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
  
  # React Native paths, needed for better integration
  # React native path for easier change between monorepo and not
  # Your 'node_modules' directory is probably in the root of your project,
  # but if not, adjust the `:path` accordingly  
  rn_path = "#{node_modules_path}/react-native" 
  
  pod 'React', :path => rn_path, :subspecs => [
    'CxxBridge', # Include this for RN >= 0.47
    'Core',
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # Needed for debugging
    'RCTAnimation', # Needed for FlatList and animations running on native UI thread
    # Add any other subspecs you want to use in your project
  ]
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => "#{rn_path}/ReactCommon/yoga"
  
  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

  # Pods for DiwalaMobile
  # Required by RNFirebase
  pod 'Firebase/Core', '~> 5.20.1'
  pod 'GoogleAppMeasurement', '5.8.0'
  pod 'Firebase/Messaging'
  pod 'Firebase/Database'
  pod 'Firebase/Auth'
  
  # Intercom SDK
  pod 'Intercom'

  # Other injections of react native libraries
  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

  target 'DiwalaMobileTests' do
    inherit! :search_paths
    # Pods for testing
  end

   # this is needed to avoid including multiple references to react.
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end

      targets_to_ignore = %w(React yoga)
          
      if targets_to_ignore.include? target.name
        target.remove_from_project
      end
    end
  end

end

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.

  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'


  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

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.