Closed rguzmangraviti closed 1 year ago
Likely missing the import here
https://rnfirebase.io/#configure-firebase-with-ios-credentials
#import <Firebase.h>
Side note, you can format your code blocks in github markdown using triple-backticks and a language specifier (in this case I used objective-c
, but might be json
or typescript
or whatever) like I did above ☝️ and it really helps those reading
Solved here -> https://github.com/invertase/react-native-firebase/issues/6625#issuecomment-1288769575
In summary the issue is that you are putting the import inside an if
sentence
`#import "AppDelegate.h"
import <React/RCTBridge.h>
import <React/RCTBundleURLProvider.h>
import <React/RCTRootView.h>
import <React/RCTAppSetupUtils.h>
if RCT_NEW_ARCH_ENABLED
import
import <FirebaseCore/FIRApp.h>
import “CDVGoogleAnalytics.m”
import <React/CoreModulesPlugins.h>
import <React/RCTCxxBridgeDelegate.h>
import <React/RCTFabricSurfaceHostingProxyRootView.h>
import <React/RCTSurfacePresenter.h>
import <React/RCTSurfacePresenterBridgeAdapter.h>
import <ReactCommon/RCTTurboModuleManager.h>
import <react/config/ReactNativeConfig.h>
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> { RCTTurboModuleManager _turboModuleManager; RCTSurfacePresenterBridgeAdapter _bridgeAdapter; std::shared_ptr _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
@end
endif
@implementation AppDelegate
(BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions { [FIRApp configure]; RCTAppSetupPrepareApp(application);
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
if RCT_NEW_ARCH_ENABLED
_contextContainer = std::make_shared();
_reactNativeConfig = std::make_shared();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
endif
NSDictionary initProps = [self prepareInitialProps]; UIView rootView = RCTAppSetupDefaultRootView(bridge, @"appgraviti", initProps);
if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { rootView.backgroundColor = [UIColor whiteColor]; }
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; }
/// This method controls whether the
concurrentRoot
feature of React18 is turned on or off. /// /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). /// @return:true
if theconcurrentRoot
feture is enabled. Otherwise, it returnsfalse
.(BOOL)concurrentRootEnabled { // Switch this bool to turn on and off the concurrent root return true; }
(NSDictionary )prepareInitialProps { NSMutableDictionary initProps = [NSMutableDictionary new];
ifdef RCT_NEW_ARCH_ENABLED
initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
endif
return initProps; }
if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
endif
}
if RCT_NEW_ARCH_ENABLED
pragma mark - RCTCxxBridgeDelegate
pragma mark RCTTurboModuleManagerDelegate
(Class)getModuleClassFromName:(const char *)name { return RCTCoreModulesClassProvider(name); }
(std::shared_ptr)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr)jsInvoker
{
return nullptr;
}
(std::shared_ptr)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}
(id)getModuleInstanceFromClass:(Class)moduleClass
{
return RCTAppSetupDefaultModuleFromClass(moduleClass);
}
endif
@end `
Issue
Use of undeclared identifier 'FIRApp'
Describe your issue here
The problem is only in ios, inside the appDelegate when it is used![Captura de Pantalla 2022-10-05 a la(s) 19 33 43](https://user-images.githubusercontent.com/98415258/194189332-6e09ef63-bb72-4d2f-8133-2c7b2e5cf437.png)
[FIRApp configure];
Project Files
Javascript
Click To Expand
#### `package.json`: `{ "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@fortawesome/free-brands-svg-icons": "^6.2.0", "@fortawesome/pro-light-svg-icons": "^6.2.0", "@fortawesome/pro-regular-svg-icons": "^6.2.0", "@fortawesome/pro-solid-svg-icons": "^6.2.0", "@kichiyaki/react-native-barcode-generator": "^0.6.7", "@react-native-firebase/analytics": "^15.7.0", "@react-native-firebase/app": "^15.7.0", "@react-navigation/bottom-tabs": "^6.3.2", "@react-navigation/material-bottom-tabs": "^6.2.2", "@react-navigation/native": "^6.0.11", "@react-navigation/native-stack": "^6.7.0", "@rneui/base": "^0.0.0-edge.2", "@rneui/themed": "^0.0.0-edge.2", "formik": "^2.2.9", "intl": "^1.2.5", "prop-types": "^15.8.1", "react": "18.0.0", "react-native": "^0.69.4", "react-native-animated-pagination-dots": "^0.1.72", "react-native-autocomplete-dropdown": "^2.0.7", "react-native-calendars": "^1.1288.0", "react-native-config": "^1.4.6", "react-native-currency-input": "^1.0.1", "react-native-fontawesome-pro": "^2.1.0", "react-native-gifted-charts": "^1.2.41", "react-native-linear-gradient": "^2.6.2", "react-native-safe-area-context": "^4.3.1", "react-native-screens": "^3.15.0", "react-native-share": "^7.8.0", "react-native-svg": "^12.4.4", "react-native-uuid": "^2.0.1", "react-native-vector-icons": "^9.2.0", "yup": "^0.32.11" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.6.3", "eslint": "^7.32.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.70.3", "react-test-renderer": "18.0.0" }, "jest": { "preset": "react-native" } } ` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```
iOS
Click To Expand
#### `ios/Podfile`: require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '12.4' install! 'cocoapods', :deterministic_uuids => false $FirebaseSDKVersion = '9.6.0' $RNFirebaseAnalyticsWithoutAdIdSupport=true production = ENV["PRODUCTION"] == "1" target 'appgraviti' do config = use_native_modules! pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons' pod 'FirebaseCoreDiagnostics', '1.2.1' # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :production => production, :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], :flipper_configuration => FlipperConfiguration.enabled, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'appgravitiTests' do inherit! :complete # Pods for testing end post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end #### `AppDelegate.m`: #import "AppDelegate.h" #import
#import
#import
#import
#if RCT_NEW_ARCH_ENABLED
#import
#import
#import “CDVGoogleAnalytics.m”
#import
#import
#import
#import
#import
#import
#import
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
@interface AppDelegate () {
RCTTurboModuleManager *_turboModuleManager;
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
std::shared_ptr _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
RCTAppSetupPrepareApp(application);
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
#if RCT_NEW_ARCH_ENABLED
_contextContainer = std::make_shared();
_reactNativeConfig = std::make_shared();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif
NSDictionary *initProps = [self prepareInitialProps];
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"appgraviti", initProps);
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
// Switch this bool to turn on and off the concurrent root
return true;
}
- (NSDictionary *)prepareInitialProps
{
NSMutableDictionary *initProps = [NSMutableDictionary new];
#ifdef RCT_NEW_ARCH_ENABLED
initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
#endif
return initProps;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
#if RCT_NEW_ARCH_ENABLED
#pragma mark - RCTCxxBridgeDelegate
- (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
delegate:self
jsInvoker:bridge.jsCallInvoker];
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}
#pragma mark RCTTurboModuleManagerDelegate
- (Class)getModuleClassFromName:(const char *)name
{
return RCTCoreModulesClassProvider(name);
}
- (std::shared_ptr)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr)jsInvoker
{
return nullptr;
}
- (std::shared_ptr)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}
- (id)getModuleInstanceFromClass:(Class)moduleClass
{
return RCTAppSetupDefaultModuleFromClass(moduleClass);
}
#endif
@end