iosxcodereact-nativefbsdkreact-native-fbsdk

Facebook Login implementation failing for React Native App


I've been trying to implement Facebook Login functionality for react native app. Sad how a language developed by Facebook is not properly supporting its own functionalities. Here is the process I've followed:

  1. I installed https://www.npmjs.com/package/react-native-fbsdk-next package as npm i react-native-fbsdk-next which installed "^4.0.0" of this.
  2. I did pod install and it shows a success message as shown in the image below: enter image description here
  3. Then I opened the iOS project in XCode and added this in my info.plist file:
<key>CFBundleURLTypes</key>
  <array>
      <dict>
          <key>CFBundleURLSchemes</key>
          <array>
              <string>fbMY_APP_ID</string>
          </array>
      </dict>
  </array>
  <key>FacebookAppID</key>
  <string>MY_APP_ID</string>
  <key>FacebookDisplayName</key>
  <string>MY_APP_NAME</string>
  <key>LSApplicationQueriesSchemes</key>
  <array>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
  </array>
  1. After that I opened AppDelegate.m and did the following:
...
#import <FBSDKCoreKit/FBSDKCoreKit.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
  
  [[FBSDKApplicationDelegate sharedInstance] application:application
      didFinishLaunchingWithOptions:launchOptions];
  
  return YES;
}

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
    return YES;
  }

  return NO;
}

...

Then when I run the app react-native run-ios there is this really long error that appears and I cannot even copy the full one but here are the last few lines of that error:

Full Log of this error is posted https://github.com/thebergamo/react-native-fbsdk-next/issues/11

** BUILD FAILED **

The following build commands failed: Ld /Users/chaudhrytalha/Library/Developer/Xcode/DerivedData/fbexampleapp-cbjnhmdbrulusmcwnknqvzbhuegw/Build/Products/Debug-iphonesimulator/fbexampleapp.app/fbexampleapp normal

The failer message is ever larger than that.

So far what I've tried is I've started a new project from scratch made sure it's running and the moment I install react-native-fbsdk-next and then update pod and run the app again it starts to show this long error.


Solution

  • Open your project in xcode and create an empty .swift file in your project enter image description here

    click next and your project will build