When attempting to archive a release version of the app, the build fails with the following error:
use of undeclared identifier 'FBSDKApplicationDelegate'
The incriminating file is AppDelegate.m, in the two methods that the "Get Started" guide recommends tweaking in this file (didFinishLaunchingWithOptions and openURL).
I have been able to reproduce the issue with a fresh project:
# Our main project is using TypeScript:
react-native init FBSDKErrorReproduction --template react-native-template-typescript
yarn add react-native-fbsdk
cd ios
pod install
After completing those steps and adding didFinishLaunchingWithOptions and openURL to AppDelegate.m, verify the app runs fine in the simulator. However, a production build will fail with the following error:

For searchability purposes:
/Users/aurelien/Projects/xxx/ios/yyy/AppDelegate.m:36:5: error: use of undeclared identifier 'FBSDKApplicationDelegate'
[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
^
/Users/aurelien/Projects/xxx/ios/yyy/AppDelegate.m:66:20: error: use of undeclared identifier 'FBSDKApplicationDelegate'
BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
^
2 errors generated.
The production build completes with no error.
Here is a minimal repository reproducing the issue: https://github.com/aurelienshz/fbsdk-build-error-repro
System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Memory: 168.85 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.14.1 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.6.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.3, 27.0.3, 28.0.3
System Images: android-22 | Google APIs ARM EABI v7a, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6308749
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_192 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.1 => 0.62.1
npmGlobalPackages:
*react-native*: Not Found
I ran into this today also.
From the FB iOS quickstart guide at https://developers.facebook.com/quickstarts/:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
Weeelllll...
One the one hand, I was missing the applicationDidBecomeActive part. But I don't think that could be the issue here.
On the other hand, now that I have added it, I have 3 build errors instead of two!

Thanks for chiming in, but it looks like we're still looking for a solution here 馃檪
After starting to question my own sanity, I realized that I had mindlessly put the #import <FBSDKCoreKit/FBSDKCoreKit.h> after the last import and before the first method definition of AppDelegate.m:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#if DEBUG
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}
#endif
...which puts #import <FBSDKCoreKit/FBSDKCoreKit.h> right in the middle of an #if DEBUG/#endif block
...which makes it perfectly normal and expected that the identifiers brought by this import aren't declared when archiving a release build.
~I will now contemplate all my life choices and consider switching careers.~
Thanks for your help!
Thanks, @aurelienshz,
In my case, the import statements are in the middle of this block #ifdef FB_SONARKIT_ENABLED / #endif
After taking them back from the blocks, archiving was succeeded.
Before:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
...
#endif
After:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
...
#endif
Most helpful comment
After starting to question my own sanity, I realized that I had mindlessly put the
#import <FBSDKCoreKit/FBSDKCoreKit.h>after the last import and before the first method definition ofAppDelegate.m:...which puts
#import <FBSDKCoreKit/FBSDKCoreKit.h>right in the middle of an#if DEBUG/#endifblock...which makes it perfectly normal and expected that the identifiers brought by this import aren't declared when archiving a release build.
~I will now contemplate all my life choices and consider switching careers.~
Thanks for your help!