facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 908 forks source link

React/RCTBridgeModule.h file not found #638

Closed lsantamaria closed 4 years ago

lsantamaria commented 5 years ago

I am receiving this error after installling the fbsdk to my RN project and running it on iOS. It seems that all the references or imports are referring to "React" instead of "React-Core", so the build fails because it does not find the modules.

If I am changing all the references from React/X to React-Core/React/X it works. More explanation in this post.

So I had to rename all the .h files to get it working temporarily. Any cleaner idea to get it working?

ancyrweb commented 4 years ago

Had the same problem this morning. As of myself the problem was a configuration problem. I just moved from 0.59.0 to 0.61.0-rc.3 and installed React-Native and its dependencies through Cocoapods. Unfortunately this is a one-year old project and it used to include binaries directly into Build Phases -> Link Binary With Libraries..

I solved the problem by removing everything in here and adding libPods-myProject.a (the binary file generated by cocoapods).

I copied the Podfile file directly from https://react-native-community.github.io/upgrade-helper/ and now it works perfectly fine.

lsantamaria commented 4 years ago

Hi @rewieer, I tried what you say and then I got this error:

 *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: null is not an object (evaluating 'n.logInWithPermissions')', reason: 'Unhandled JS Exception: null is not an object (evaluating 'n.logInWithPermissions'), stack:
logInWithPermissions@1002:137

So that I decided to add there(Build Phases) libRCTFBSDK.a, and then is when the problem with React and React-Core naming arises.

This is my Podfile:

# platform :ios, '9.0'

target 'myProject' do
  # use_frameworks!
  # Pods for myProject
    rn_path = '../node_modules/react-native'
    pod 'React', :path => '../node_modules/react-native'
    pod 'React-Core', :path => '../node_modules/react-native/React'
    pod 'React-DevSupport', :path => '../node_modules/react-native/React'
    pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
    pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
    pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
    pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
    pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
    pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
    pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
    pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
    pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
    pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
    pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
    pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
    pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
    pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
    pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
    pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
    pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIos'
    pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
    pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
    pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
    pod 'RNFS', :path => '../node_modules/react-native-fs'
    pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
    pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
    pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
    pod 'FBSDKCoreKit'
    pod 'FBSDKLoginKit'
    pod 'FBSDKShareKit'
    pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
    pod 'react-native-image-resizer', :path =>  '../node_modules/react-native-image-resizer'
    pod 'RNImageCropPicker', :path =>  '../node_modules/react-native-image-crop-picker'
    pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec'
    pod 'RNReanimated', :path => '../node_modules/react-native-reanimated/RNReanimated.podspec'
  target 'myProject-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
    #pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
  end

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

  # very important to have, unless you removed React dependencies for Libraries
  # and you rely on Cocoapods to manage it
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

end

Do you know how can I get this working?

lsantamaria commented 4 years ago

I solved it finally without adding libRCTFBSDK.a.

The problem was on the Podfile, the last section was removing React from the Targets, and I have needed to add this lines:

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
use_native_modules!

So, in conclusion, the problem was that after upgrading to 0.60, the Podfile was not correctly upgraded so React module was not added to the iOS target.