React Native集成Firebase后iOS构建失败:FirebaseCoreInternal.modulemap缺失
解决iOS构建「FirebaseCoreInternal.modulemap' not found」错误
1. 彻底清理并重装CocoaPods依赖
- 删除
ios/Pods文件夹和ios/Podfile.lock文件 - 清理本地CocoaPods缓存:
pod cache clean --all - 进入ios目录执行:
pod install --repo-update要是你用了
use_frameworks! :linkage => :static,得保证Firebase相关组件的模块化配置没冲突
2. 修正Podfile的模块化头配置
在Podfile里明确给Firebase相关组件开启模块化头,比如:
# 单独指定Firebase组件的模块化配置 pod 'FirebaseCore', :modular_headers => true pod 'FirebaseFirestore', :modular_headers => true pod 'FirebaseCoreInternal', :modular_headers => true pod 'FirebaseSharedSwift', :modular_headers => true
要是项目允许,也可以批量给所有依赖开启:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['CLANG_ENABLE_MODULES'] = 'YES' config.build_settings['USE_HEADERMAP'] = 'NO' end end end
3. 检查Xcode项目的路径配置
- 打开Xcode,找到项目的Build Settings
- 搜索
Header Search Paths,确保包含$(inherited)和${PODS_ROOT}/FirebaseCoreInternal/Headers - 搜索
Framework Search Paths,添加$(inherited)和${PODS_ROOT}/FirebaseCoreInternal
4. 清空Xcode构建缓存
- 按
Cmd+Shift+K清理当前项目的构建缓存 - 关闭Xcode,删除
~/Library/Developer/Xcode/DerivedData下对应项目的缓存文件夹 - 重新打开Xcode并尝试构建
5. 核对版本兼容性
确认@react-native-firebase/app和@react-native-firebase/firestore的21.0.0版本和你当前的React Native版本兼容,要是RN版本太低,可能得升级RN或者降级Firebase依赖
内容的提问来源于stack exchange,提问作者Haim Madar
相关产品推荐
相关产品推荐

