How to fix “Invariant Violation: requireNativeComponent: ”RCTFBLoginButton“ was not found in the UIManager.”?

ぃ、小莉子 提交于 2021-01-27 05:24:16

问题


Let me start by saying that similar SO questions suggest the problem may be related to not having linked the lib.

I've ran react-native link react-native-fbsdk again, to confirm it was indeed linked, and confirmed it was

rnpm-install info Platform 'ios' module react-native-fbsdk is already linked
rnpm-install info Platform 'android' module react-native-fbsdk is already linked

Still, I see a couple of red indications in my XCode project for main.jsbundle, libReact.a and libRCTFBSDK.a (which I find especially disturbing to be showing under "Recovered References", and to be pointing to nowhere when I try to locate it in Finder). So, all in all, strong indications that something (or some things) went wrong with my FBSDK setup.

Because these are mentioned in the setup guides, let me go ahead an report that:

  1. I've downloaded the SDK, which is extracted under my ~/Documents/FacebookSDK folder
  2. I've dragged the 4 frameworks (Bolts, FBSDKCoreKit, FBSDKLoginKit, FBSDKShareKit) into the project, not marking the "Copy" option
  3. My "Build Settings" >> "Framework Search Paths" has ~Documents/FacebookSDK for value (and just that, nothing else)
  4. My "Build Settings" >> "Other Linker Flags" has -ObjC -lc++ for value (this was already so, I didn't touch it, just confirmed it had ObjC, per Facebook's guide)
  5. My "Build Phases" >> "Link Binary With Libraries" has the 4 frameworks, plus several others files, including the two that are in red in the tree (libReact.a and libRCTFBSDK.a)

While it does seem the problem is rooted in those red files, I'm out of clues or luck in trying to fix them, so any help is appreciated!


回答1:


I have been struggling with that a lot of time. After some investigation and several tries, I solved it this way:

  • Remove node_modules and ios/Pods
  • Upgraded to react-native 0.60
  • npm install
  • Added this to Podfile:
    pod 'FBSDKCoreKit'
    pod 'FBSDKLoginKit'
    pod 'FBSDKShareKit'
  • from ios folder: ```pod install ````

  • configure AppDelegate and Info.plist as this guide states

I did not have to manually drag the frameworks to the Xcode project as the guide say.




回答2:


As of the moment of this issue, the react-native-fbsdk github indicates this guide should be followed, with the exception of step 2 (Linking the SDK), with the frameworks being dragged into the project instead. That's similar to what's indicated at the "Quick Start" guide you get to from inside FB's Dashboard. Both those guides were the source of the issues I was seeing.

Following this guide instead got it working.



来源:https://stackoverflow.com/questions/54124766/how-to-fix-invariant-violation-requirenativecomponent-rctfbloginbutton-was

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!