You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RNFBApp报错:'React/RCTVersion.h'文件未找到(RN0.70升级至0.72.6后)

解决RNFBApp报错'React/RCTVersion.h'未找到的问题

核心问题分析

你的Podfile存在两个关键问题:

  • 注释掉了use_react_native!调用,导致React Native核心组件的头文件路径没有被正确注入到Xcode项目中
  • 手动引入@react-native-firebase系列pod,和RN自动模块配置逻辑冲突

修复步骤

1. 修改Podfile内容

替换为以下配置(保留你的Firebase自定义配置,修复核心逻辑):

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, '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 'LionAir' do
  # 启用自动模块配置
  config = use_native_modules!

  # 恢复React Native核心配置
  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => true,
    :flipper_configuration => flipper_config,
  )

  use_frameworks!
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseFirestore', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseFirestoreInternal', :modular_headers => true
  pod 'FirebaseInAppMessaging', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'FirebaseABTesting', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'TrustKit'

  $RNFirebaseAsStaticFramework = true
  
  # 移除手动引入的RNFB pods,由use_native_modules!自动处理
  # pod 'RNFBMessaging', :path => '../node_modules/@react-native-firebase/messaging'
  # pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'
  # pod 'RNFBAnalytics', :path => '../node_modules/@react-native-firebase/analytics'
  # pod 'RNFBInAppMessaging', :path => '../node_modules/@react-native-firebase/in-app-messaging'
  # pod 'RNFBAuth', :path => '../node_modules/@react-native-firebase/auth'

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath]
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

target 'imagenotification' do
  use_frameworks!
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'Firebase/Messaging',:modular_headers => true
end

2. 清理并重新安装依赖

执行以下命令:

# 进入ios目录
cd ios
# 删除缓存和锁定文件
rm -rf Pods Podfile.lock build
# 清除Xcode缓存
xcodebuild clean -all
# 重新安装Pods
pod install

3. Xcode中验证配置

  • 打开LionAir.xcworkspace(不要打开xcodeproj)
  • 确认项目的Build Settings中,Header Search Paths包含React Native的头文件路径(由pod自动配置)

关键说明

  • use_react_native!是RN 0.70+ Podfile的核心配置,负责注入React Native的编译依赖和头文件路径,不能注释
  • use_native_modules!会自动处理所有兼容的第三方库,包括@react-native-firebase系列,手动引入会导致依赖冲突
  • $RNFirebaseAsStaticFramework = true必须保留,确保Firebase模块以静态框架方式编译,适配RN 0.72架构

内容的提问来源于stack exchange,提问作者Pavitran

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 01:41:01