iOS构建React Native应用报错:未声明标识符FBSDKApplicationDelegate
iOS构建报错:use of undeclared identifier 'FBSDKApplicationDelegate'
安装react-native-fbsdk-next并完成配置步骤后,常规构建iOS应用时出现以下报错,导致应用无法构建:error: use of undeclared identifier 'FBSDKApplicationDelegate'
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
依赖版本信息
"react": "18.2.0", "react-native": "0.71.2", "react-native-fbsdk-next": "^11.2.0",
Podfile.lock中的Facebook相关依赖:
- FBAEMKit (15.0.0): - FBSDKCoreKit_Basics (= 15.0.0) - 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配置(ID为实际应用编号)
<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>
已尝试的解决方法
- 将
#import <FBSDKCoreKit/FBSDKCoreKit.h>改为#import <FBSDKCoreKit/FBSDKCoreKit-Switch.h>,应用可构建但启动崩溃 - 删除Pods、清除派生数据、卸载模拟器中的应用,问题仍未解决
内容的提问来源于stack exchange,提问作者Patrycja Trzcińska
相关产品推荐
相关产品推荐

