React-native-code-push: Use of undeclared identifier 'CodePush

Created on 2 Jul 2020  路  5Comments  路  Source: microsoft/react-native-code-push

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Steps to Reproduce

1.


  1. 3.

Expected Behavior

What you expected to happen?

Actual Behavior

What actually happens?

  STACK TRACE AND/OR SCREENSHOTS

Reproducible Demo

Environment

  • react-native-code-push version:
  • react-native version:
  • iOS/Android/Windows version:
  • Does this reproduce on a debug build or release build?
  • Does this reproduce on a simulator, or only on a physical device?

(The more info the faster we will be able to address it!)

Most helpful comment

I have managed to fix it

import

import

import

import . ----> Import should be above the #ifdef FB_SONARKIT_ENABLED

All 5 comments

Hi @ma569322307 ,
Thanks for reporting!

Could you please fill description of the issue and provide some details like logs or/and demo app with reproducing issue and reprosteps that help us reproduce and investigate the issue?

Facing the same issue, created a POC on the following version

  • "react": "16.13.1",
  • "react-native": "0.63.0",
  • "react-native-code-push": "^6.2.1"

It is happening only when archiving the build

Error
Use of undeclared identifier 'CodePush' in AppDelegate.m

I have managed to fix it

import

import

import

import . ----> Import should be above the #ifdef FB_SONARKIT_ENABLED

@Shashank2406 It works for me. I came to the same issue. It was resolved by moving all header files before the line #ifdef FB_SONARKIT_ENABLED as what you said.

Error when archiving on iOS

error

Before moving

#import "AppDelegate.h"

#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 <RCTJPushModule.h>
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
#import <UserNotifications/UserNotifications.h>
#endif

#import "Orientation.h"
#import <CodePush/CodePush.h>
#import "RNSplashScreen.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

After moving

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <RCTJPushModule.h>
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
#import <UserNotifications/UserNotifications.h>
#endif

#import "Orientation.h"
#import <CodePush/CodePush.h>
#import "RNSplashScreen.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>

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

Thanks so much.

Hi all,

Unfortunately, I can't reproduce it but I see that you found a solution.
So, I'm going to close this issue as the issue was resolved.
Please feel free to reopen it if you have any questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osdnk picture osdnk  路  3Comments

Fuhrmann picture Fuhrmann  路  3Comments

ACCTFORGH picture ACCTFORGH  路  3Comments

SudoPlz picture SudoPlz  路  4Comments

quanzaiyu picture quanzaiyu  路  3Comments