Closed aurelienshz closed 4 years ago
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
🐛 Bug Report
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
andopenURL
).To Reproduce
I have been able to reproduce the issue with a fresh project:
After completing those steps and adding
didFinishLaunchingWithOptions
andopenURL
to AppDelegate.m, verify the app runs fine in the simulator. However, a production build will fail with the following error:For searchability purposes:
Expected Behavior
The production build completes with no error.
Code Example
Here is a minimal repository reproducing the issue: https://github.com/aurelienshz/fbsdk-build-error-repro
Environment