React-native: XCode Build works Archive fails

Created on 16 May 2020  路  10Comments  路  Source: facebook/react-native

I'm developing an app with react native. I built it successfully in XCode and installed it in my iPhone. All correct, I've got the app installed and working fine in my device. Then I want to upload the app to the Store -> archive -> error!

Any module used in AppDelegate.m -> didFinishLaunchingWithOptions causes the error "use of undeclared identifier 'module'.

For example, I'm using Firebase, you need to insert these lines:
@import Firebase; // this is ok

(in didFinishLaunchingWithOptions) [FIRApp configure];
ERROR -> Use of undeclared identifier 'FIRApp'

Same with google Maps/Places:

@import GooglePlaces;
@import GoogleMaps; // this is ok
....
[GMSPlacesClient provideAPIKey:@"xxxxxxxxxxxxx"];
[GMSServices provideAPIKey:@"xxxxxxxxxx"];
ERROR -> use of undeclared identifier 'GMSPlacesClient' or 'GMSServices'

React Native version:

0.62.2, I always used this version, never upgraded.

Steps To Reproduce

Create a new project with react-native 0.62.2. Install any module that requires a change in the file appDelegate.m, for example Firebase, as explained in https://rnfirebase.io/, install pods, open XCode, build successfully. Then try to archive.

Expected Results

The archive should be built successfully.

Other comments

I have read a lot of possible solutions about Cocoapods. I doubt this is my problem, pod install was successfull, my modules are working fine. I have the app installed in my iPhone and firebase and google maps are working correctly. Build works.

Needs

Most helpful comment

In my case was this moron #ifdef FB_SONARKIT_ENABLED

Wrong

#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 <React/RCTLinkingManager.h>
#import <Firebase.h>

Correct

#import <React/RCTLinkingManager.h>
#import <Firebase.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>

All 10 comments

My bad, I've noticed that @import for these modules was way below #if DEBUG, that's why it didn't work.

My bad, I've noticed that @import for these modules was way below #if DEBUG, that's why it didn't work.

Thanks a lot, I don't know how I had missed this.

My bad, I've noticed that @import for these modules was way below #if DEBUG, that's why it didn't work.

saved my life ! spent few hours about this...

in my case it was AppCenterReactNative:

Use of undeclared identifier 'AppCenterReactNative'

in case someone will search for the specific error as I did

You just saved my life. Thanks

@oscarsales I'm laughing to myself so hard

Screen Shot 2020-09-19 at 13 08 37

thanks for the answer

In my case was this moron #ifdef FB_SONARKIT_ENABLED

Wrong

#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 <React/RCTLinkingManager.h>
#import <Firebase.h>

Correct

#import <React/RCTLinkingManager.h>
#import <Firebase.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>

In my case was this moron #ifdef FB_SONARKIT_ENABLED

@MFrat nice catch,

Thanks!

I

@oscarsales I'm laughing to myself so hard

Screen Shot 2020-09-19 at 13 08 37

thanks for the answer

I knew you are not the only one 馃槀

In my case was this moron #ifdef FB_SONARKIT_ENABLED

Wrong

#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 <React/RCTLinkingManager.h>
#import <Firebase.h>

Correct

#import <React/RCTLinkingManager.h>
#import <Firebase.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>

Thanks, it worked for me.

Ok, I see there are a lot of not native iOS developers :)

+1 to your club

Was this page helpful?
0 / 5 - 0 ratings