user567
user567

Reputation: 3872

react native app do not build after adding @react-native-firebase/storage

In my react native project I am trying to add multiple firebase services, but I am getting an error

'FirebaseStorage/FirebaseStorage-Swift.h' file not found

Package.josn

"@react-native-firebase/app": "^16.4.3",
    "@react-native-firebase/auth": "^16.4.3",
    "@react-native-firebase/crashlytics": "^16.4.3",
    "@react-native-firebase/database": "^16.4.3",
    "@react-native-firebase/dynamic-links": "^16.4.3",
    "@react-native-firebase/firestore": "^16.4.3",
    "@react-native-firebase/messaging": "^16.4.3",
    "@react-native-firebase/storage": "^16.4.3",

Podfile

pod_folder = Pathname.new(__FILE__).dirname.realpath

pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

require File.join(File.dirname(`cd #{pod_folder} && node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`cd #{pod_folder} && node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`cd #{pod_folder} && node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

platform :ios, '12.1'

pod 'Firebase', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseAppCheckInterop', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'GTMSessionFetcher', :modular_headers => true


require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}

target 'MyApp' do
  use_expo_modules!
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes'
  )

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!({ 'Flipper' => '0.95.0', 'Flipper-Folly' => '2.6.7', 'Flipper-DoubleConversion' => '3.1.7' })
    post_install do |installer|
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.1'
            ## Fix for XCode 12.5
            find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
            "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
            find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
                "RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
      end
      react_native_post_install(installer)
    endMyApp
end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

If I delete the @react-native-firebase/storage module the app works again.

Upvotes: 0

Views: 1079

Answers (1)

Vu Phung
Vu Phung

Reputation: 715

May be you need change something in Podfile:

Replacing use_frameworks! by use_frameworks! :linkage => :static Moving $RNFirebaseAsStaticFramework = true from top of file to next line of use_frameworks Uncomment line :flipper_configuration => FlipperConfiguration.enabled, & replace enabled with disabled

More information: https://github.com/invertase/react-native-firebase/issues/6382#issuecomment-1276756506

Upvotes: 1

Related Questions