React_Coder
React_Coder

Reputation: 428

After installing react-native-firebase/app it's Build will failed in react-native ios

After installing react-native-firebase/[email protected] with react-native-0.68.1 using use_frameworks! and remove flipperin the podfile of the project , but when i ran npx react-native run-ios it's Build failed

The following build commands failed: Ld /Users/userName/Library/Developer/Xcode/DerivedData/-gvnovwrlbjvxedcquaumtvgvdgmn/Build/Products/Debug-iphonesimulator/react-native-razorpay/react_native_razorpay.framework/react_native_razorpay normal (in target 'react-native-razorpay' from project 'Pods') (1 failure) , The Project also contain react-native-razorpay previously added ..now what to do for removing the error and build will succeed with out any crash, Please help i am new to react-native my podfile looks like ``` #use_modular_headers!

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.0' install! 'cocoapods', :deterministic_uuids => false

target 'DussriShadi' do

use_frameworks!

config = use_native_modules!

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 :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." )

target 'DussriShadiTests' do inherit! :complete # Pods for

end

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

Upvotes: 13

Views: 9235

Answers (4)

max_dev
max_dev

Reputation: 564

The steps outlined below are still relevant with the newest versions:

    "@react-native-firebase/app": "^18.1.0",
    "@react-native-firebase/auth": "^18.1.0",
    "react-native": "0.71.10",

My only issue, after I had done all the steps, was that the app would crash with:

Error: [app/unknown] Default app has already been configured.

It turned out that this was because I had the GoogleService-Info.plist in the Xcode project, as well as having initialized Firebase in the RN project.

import {firebaseConfig} from './firebaseConfig';
import firebase from '@react-native-firebase/app';

if (!firebase.apps.length) {
  firebase.initializeApp(firebaseConfig);
}

The issue disappeared after I deleted the GoogleService-Info.plist from the Xcode project.

I'm not quite sure why the react-native-firebase official guides do not align with reality.

Upvotes: 0

Oskar Gonzalez
Oskar Gonzalez

Reputation: 39

I've solved by commenting the use_frameworks! line and then added manually all the pods necessary for Firebase. This are the setting of my Podfile.

RN: "0.71.8" Firebase: "18.0.0"

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
$RNFirebaseAsStaticFramework = true

platform :ios, min_ios_version_supported
deployment_target = '13.0'
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

target 'real_trends' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  # use_frameworks! :linkage => :static

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

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

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

Hope this helps you.

Upvotes: 3

levepi
levepi

Reputation: 19

Adding pods with modular headers (as Charlotte_Anne) do truly work but it is important NOT to use

use_frameworks!

Do not place use_frameworks! in podfile (although firebase installation instructions tell you to do so) And it works! Also encountered different problems after rebuilding (appregistry not found etc) which have many false solutions/answers and it still didnt work. What worked for me is to rebuild the project from git (git clone original project, modify podfile, pod install).

Upvotes: 1

Charlotte_Anne
Charlotte_Anne

Reputation: 382

This is what worked for me using

"@react-native-firebase/app": "^15.6.0",
"@react-native-firebase/messaging": "^15.6.0",
"react": "18.1.0",
"react-native": "0.70.1"
  1. first add this into podfile:

      pod 'Firebase', :modular_headers => true
      pod 'FirebaseCoreInternal', :modular_headers => true
      pod 'GoogleUtilities', :modular_headers => true
      pod 'FirebaseCore', :modular_headers => true
    

in between

   flags = get_default_flags()

and

   use_react_native!(
  1. Then delete podfile.lock.

  2. Then do:

      cd ios
      pod deintegrate
      pod cache clean --all
      npm cache verify
      yarn cache clean
      pod install --repo-update
    
  3. Then clean build folder under XCode -> Product -> Clean Build Folder.

  4. Then run from within XCode.

Upvotes: 15

Related Questions