Error when adding firebase to React Native iOS app

0
132

[ad_1]

I am having this error when running React-Native iOS App after adding Firebase and the googleserviceinfo.plist file. I have followed the instructions and I am Getting this error:

2022-10-04 23:35:59.711 xcodebuild[38171:508367] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x146d065c0: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/suvin/Library/Developer/Xcode/DerivedData/BoundaryTestApp-ekpfrimpksdanhevovuosfavhjwg/SourcePackages/checkouts/swift-protobuf/Sources/protoc-gen-swift/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 “Cannot open “Docs.docc” as a “Swift Package Folder” because it is already open as a “Folder”.” UserInfo={NSLocalizedDescription=Cannot open “Docs.docc” as a “Swift Package Folder” because it is already open as a “Folder”.}
** BUILD FAILED **

The following build commands failed:
CompileC /Users/suvin/Library/Developer/Xcode/DerivedData/BoundaryTestApp-ekpfrimpksdanhevovuosfavhjwg/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-logger.build/Objects-normal/arm64/react_native_log.o /Users/suvin/Documents/GitHub/react-native-geofence-example-master/node_modules/react-native/ReactCommon/logger/react_native_log.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target ‘React-logger’ from project ‘Pods’)
(1 failure)

This is my AppDelegate.m file

#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
#import "AppDelegate.h"
#import UIKit;
#import FirebaseCore;

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

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

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

[FIRApp configure];

  return YES;


#ifdef FB_SONARKIT_ENABLED
  InitializeFlipper(application);
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"BoundaryTestApp"
                                            initialProperties:nil];

  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];

  // Define UNUserNotificationCenter
  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;

  return YES;
}



- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
  completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
 [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
 [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)(void))completionHandler
{
  [RNCPushNotificationIOS didReceiveNotificationResponse:response];
}

@end

This is my package.json

{
  "name": "BoundaryTestApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/push-notification-ios": "^1.10.1",
    "@react-native-firebase/app": "^15.7.0",
    "@react-native-picker/picker": "^2.4.6",
    "@react-native/normalize-color": "^2.0.0",
    "@react-navigation/bottom-tabs": "^6.4.0",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/native-stack": "^6.9.0",
    "deprecated-react-native-prop-types": "^2.3.0",
    "react": "17.0.2",
    "react-native": "0.66.1",
    "react-native-boundary": "github:ridvanaltun/react-native-boundary#b4d143406b41e866754b5a5fd0275bbd42949ab8",
    "react-native-config": "^1.4.5",
    "react-native-elements": "^3.4.2",
    "react-native-flash-message": "^0.3.1",
    "react-native-get-location": "^2.2.1",
    "react-native-image-picker": "^4.10.0",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-maps": "0.30.1",
    "react-native-permissions": "^3.1.0",
    "react-native-picker": "^4.3.7",
    "react-native-picker-select": "^8.0.4",
    "react-native-push-notification": "^8.1.1",
    "react-native-radio-buttons-group": "^2.2.11",
    "react-native-safe-area-context": "^4.4.1",
    "react-native-screen": "^1.0.1",
    "react-native-screens": "^3.17.0",
    "react-native-simple-radio-button": "^2.7.4",
    "react-native-svg": "^13.2.0",
    "react-native-svg-transformer": "^1.0.0",
    "react-native-vector-icons": "^9.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.15.8",
    "@babel/runtime": "^7.15.4",
    "@react-native-community/eslint-config": "^3.0.1",
    "babel-jest": "^27.3.1",
    "eslint": "^8.1.0",
    "jest": "^27.3.1",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  }
}

This is my 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, '11.0'

target 'BoundaryTestApp' do
  config = use_native_modules!
  use_modular_headers!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'BoundaryTestAppTests' do
    inherit! :complete
    # Pods for testing
  end

  permissions_path="../node_modules/react-native-permissions/ios"

  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

[ad_2]