Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: use of undeclared identifier 'FBSDKApplicationDelegate'

I installed react-native-fbsdk-next. Followed configuration steps. Wanted to build app on iOS (as usual). I am getting an error: use of undeclared identifier 'FBSDKApplicationDelegate' and the app won't build.

The error:

error information

My AppDelegate.mm:

#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <react-native-splash-screen/RNSplashScreen.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"AppName";
  self.initialProps = @{};

  bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];
  [RNSplashScreen show];
  [[FBSDKApplicationDelegate sharedInstance]application:application
    didFinishLaunchingWithOptions:launchOptions];
  return didFinish;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

- (BOOL)concurrentRootEnabled
{
  return true;
}


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

@end

Specification package.json and Podfile.lock:

"react": "18.2.0",
"react-native": "0.71.2",
"react-native-fbsdk-next": "^11.2.0",

  - FBAEMKit (15.0.0):
    - FBSDKCoreKit_Basics (= 15.0.0)
  - FBLazyVector (0.71.2)
  - FBReactNativeSpec (0.71.2):
    - RCT-Folly (= 2021.07.22.00)
    - RCTRequired (= 0.71.2)
    - RCTTypeSafety (= 0.71.2)
    - React-Core (= 0.71.2)
    - React-jsi (= 0.71.2)
    - ReactCommon/turbomodule/core (= 0.71.2)
  - FBSDKCoreKit (15.0.0):
    - FBAEMKit (= 15.0.0)
    - FBSDKCoreKit_Basics (= 15.0.0)
  - FBSDKCoreKit_Basics (15.0.0)
  - FBSDKGamingServicesKit (15.0.0):
    - FBSDKCoreKit (= 15.0.0)
    - FBSDKCoreKit_Basics (= 15.0.0)
    - FBSDKShareKit (= 15.0.0)
  - FBSDKLoginKit (15.0.0):
    - FBSDKCoreKit (= 15.0.0)
  - FBSDKShareKit (15.0.0):
    - FBSDKCoreKit (= 15.0.0)

Info.plist config: (ID is a number of course)

<dict>
...
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>fbID</string>
        </array>
      </dict>
    </array>
    <key>FacebookAppID</key>
    <string>ID</string>
    <key>FacebookDisplayName</key>
    <string>AppName</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>fbapi</string>
      <string>fb-messenger-share-api</string>
      <string>fbauth2</string>
      <string>fbshareextension</string>
    </array>
</dict>

I tried to switch #import <FBSDKCoreKit/FBSDKCoreKit.h> into #import <FBSDKCoreKit/FBSDKCoreKit-Switch.h> the app build but I was unable to open the app - crash. I also tried to fix it by deleting the pods, deleting the derived data and uninstallation of the app in the emulator.

like image 802
Patrycja Trzcińska Avatar asked Oct 20 '25 23:10

Patrycja Trzcińska


1 Answers

https://github.com/thebergamo/react-native-fbsdk-next/issues/317#issuecomment-1264750053

#import <FBSDKCoreKit/FBSDKCoreKit-Swift.h>

Added this line of code fix this error.

like image 170
Ravis Farooq Avatar answered Oct 22 '25 19:10

Ravis Farooq