Release iOS build error - Use of undeclared identifier 'Twitter'

Viewed 2068

I am using react-native-twitter sign in, and followed all the steps in the official documentation, but getting

Use of undeclared identifier 'Twitter' in AppDelegate.m file

this error while Archiving the IOS app, but it works fine while running on simulator, what should be the problem ?

1 Answers

I had a similar issue. Running dev version on iOS simulator works fine, but when I try to archive app in XCode, I got Use of undeclared identifier error.

Solution

In AppDelegate.m file, find header files you included:

AppDelegate.m

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.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 <Some/Dependency.h> <--- ❌ this might be the problem

If you've imported your dependency under this line:

#ifdef FB_SONARKIT_ENABLED

please move them up to before it.

For example:

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Some/Dependency.h> <--- ✅ Right here

#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>

Reason

FB Sonar Kit or Flipper is a debugging tool. It might get disabled when archiving.

Related