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

React Native 0.71.6 iOS构建时FirebaseCoreInternal模块映射文件缺失问题求助

React Native 0.71.6 iOS构建时FirebaseCoreInternal模块映射文件缺失问题求助

各位好,我这边遇到了一个iOS构建的棘手问题,想请大家帮忙看看。

我的项目是用RN CLI搭建的React Native项目,版本是0.71.6。开发环境是XCode 16.1,Mac系统是Sequoia 15.5。Android端的构建完全没问题,但iOS这边一直卡在依赖找不到的错误上,而且看起来是和Firebase相关的。

具体的错误信息是这样的:

/Users/mattcroak/Development/firefly-mobile/ios/FireflyMobile/main.m module map file '/Users/mattcroak/Library/Developer/Xcode/DerivedData/MyApp-crdglybzvgexvscaguhxbncunctu/Build/Products/Debug-iphonesimulator/FirebaseCoreInternal/FirebaseCoreInternal.modulemap' not found

我试着导航到错误里提到的DerivedData目录,结果只看到自己的App名称和一个图标,完全找不到FirebaseCoreInternal相关的文件。

执行pod install的时候没有报错,终端里能明确看到这些Firebase组件已经安装成功:

Installing Firebase (10.20.0)
Installing FirebaseAppDistribution (10.20.0-beta)
Installing FirebaseCore (10.20.0)
Installing FirebaseCoreExtension (10.20.0)
Installing FirebaseCoreInternal (10.29.0)
Installing FirebaseCrashlytics (10.20.0)
Installing FirebaseInstallations (10.29.0)
Installing FirebaseSessions (10.29.0)

不管是用命令行运行(我用的是yarn iosDev --simulator="iPhone 16 Plus",这个命令本质是执行react-native run-ios --scheme 'MyApp-Dev' --mode 'Debug' '--simulator=iPhone 16 Plus'),还是打开XCode选对模拟器后点击构建,都会弹出这个错误。

我已经尝试了不少解决方案:

  • 因为RN版本比较老,已经在XCode里排除了arm64架构
  • 尝试更新HEADER_SEARCH_PATHS,明确引用不同的Pods路径
  • 确认每次打开的都是.xcworkspace文件,没有不小心打开.xcodeproj
  • 试过直接用npx react-native run-ios,也试过放弃命令行直接在XCode里操作
  • 清理了React Native缓存、手动删除了Derived Data、执行pod deintegrate移除所有Pods,删掉了podfile.lock和build文件夹,之后重新执行pod install(包括pod install --repo-update)

特别奇怪的是,团队里其他用相同系统(最新Sequoia)和XCode版本(16.1)的同事都能正常构建,我跟着他们的步骤检查了一遍环境和配置,看起来都完全一致,但我这边就是一直出问题。

现在项目赶时间要发布,理想情况是能先解决这个iOS构建问题撑到发布,之后再考虑迁移到Expo或者更新RN版本。毕竟Android能正常跑,同事们也能正常构建,感觉就是差了点什么小细节,但实在找不到方向了。

下面是我的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, '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 => :static
  $RNFirebaseAsStaticFramework = true
end

target 'MyApp' do
  config = use_native_modules!

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

  pod 'RNSentry', :podspec => '../node_modules/@sentry/react-native/RNSentry.podspec'
  pod 'react-native-flipper', path: '../node_modules/react-native-flipper'
  pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec'
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'
  pod 'RNFS', :path => '../node_modules/react-native-fs'
  pod 'react-native-blob-util', :path => '../node_modules/react-native-blob-util'

  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  config = use_native_modules!

  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 'MyAppTests' 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

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.07 12:14:36