Piyush Sharma
Piyush Sharma

Reputation: 31

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

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 ?

Upvotes: 3

Views: 3256

Answers (1)

glinda93
glinda93

Reputation: 8489

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.

Upvotes: 15

Related Questions