React Native iOS构建失败:找不到Firebasecoreinternal.modulemap
React Native iOS模拟器构建失败:Firebasecoreinternal.modulemap not found 修复方案
问题背景
- React Native项目iOS构建,最低目标版本15.5
- 仅能在「我的Mac(为iPhone设计)」选项下成功构建,iPhone 13 Pro(15.5)等模拟器均失败
- 已尝试操作:删除
Podfile.lock、执行pod install、指定特定模拟器运行 - 错误提示:
Firebasecoreinternal.modulemap not found
相关代码
Podfile
project 'app.xcodeproj' # 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, '15.5' prepare_react_native_project! 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 "app" do config = use_native_modules! pod "Firebase", :modular_headers => true pod "FirebaseCoreInternal", :modular_headers => true pod "GoogleUtilities", :modular_headers => true pod "FirebaseCore", :modular_headers => true use_react_native!( :path => config[:reactNativePath], :app_path => "#{Pod::Config.instance.installation_root}/..", ) target "appTests" do inherit! :complete # Pods for testing end post_install do |installer| react_native_post_install( installer, config[:reactNativePath], :mac_catalyst_enabled => false, ) end end
AppDelegate.m
#import "AppDelegate.h" #import <Firebase.h> #import <IntercomModule.h> #import <React/RCTBundleURLProvider.h> @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FIRApp configure]; self.moduleName = @"app"; self.initialProps = @{}; [IntercomModule initialize:@"ios_sdk-" withAppId:@""]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { return [self getBundleURL]; } - (NSURL *)getBundleURL { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } @end
修复步骤
1. 优化Podfile的Firebase依赖配置
逐个指定Firebase组件的模块化头文件容易引发模块映射冲突,改为全局启用模块化头文件:
- 删除Podfile中手动添加的4行Firebase相关pod声明
- 在
target "app"块内添加use_modular_headers!
修改后的关键代码片段:
target "app" do config = use_native_modules! use_modular_headers! # 全局启用模块化头文件 use_react_native!( :path => config[:reactNativePath], :app_path => "#{Pod::Config.instance.installation_root}/..", ) # 其他内容保持不变 end
2. 彻底清理缓存并重建依赖
执行以下命令清理所有缓存文件,重新安装Pods:
# 清理本地缓存和构建文件 rm -rf ios/Pods ios/Podfile.lock rm -rf ~/Library/Caches/CocoaPods rm -rf ios/build/ # 重新安装Pods cd ios && pod install --repo-update
3. 检查Xcode项目配置
- 打开Xcode,进入项目Build Settings,搜索
Module Map,确认FirebaseCoreInternal的模块路径指向Pods/Headers/Private/FirebaseCoreInternal/module.modulemap - 检查
Framework Search Paths是否包含$(inherited)和Pods/FirebaseCoreInternal - 确保项目的Valid Architectures包含当前模拟器的架构(如x86_64或arm64)
4. 验证SDK版本兼容性
确认react-native-firebase版本与当前React Native版本兼容,若版本不匹配,升级或降级到对应兼容版本。
内容的提问来源于stack exchange,提问作者Mohammad Fahad Rao
相关产品推荐
相关产品推荐

