M1 Pro Mac仅Debug模式报错<FirebaseCore/FirebaseCore.h>文件找不到求助
解决M1 Mac下React Native Debug模式找不到FirebaseCore.h的问题
针对性修复方案:
1. 精准配置Podfile架构与模块化设置
修改Podfile,仅在Debug模式下适配M1架构,并强制Firebase模块开启模块化编译:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| # 仅Debug模式下排除模拟器arm64架构 if config.name == 'Debug' config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' end end # 给所有Firebase相关target开启模块化定义 if target.name.start_with?('Firebase') target.build_configurations.each do |config| config.build_settings['DEFINES_MODULE'] = 'YES' end end end end
执行命令重置Pods:
pod deintegrate && pod install
2. 修正Xcode Debug Scheme配置
打开Xcode的Scheme设置(Product > Scheme > Edit Scheme):
- 切换到
Run > Info标签页 - 确认
Build Configuration为Debug - 将
Executable指定为你的App名称(不要选Ask On Launch) - 勾选
Debug executable选项
3. 清理模拟器架构缓存
关闭Xcode和所有模拟器,执行以下命令清空模拟器缓存:
xcrun simctl shutdown all xcrun simctl erase all
重启Xcode后执行Cmd + Shift + K清理Build Folder,再尝试Debug运行。
4. 检查主项目Header Search Paths
在主项目的Build Settings中找到Header Search Paths,Debug模式下添加:
$(SRCROOT)/Pods/FirebaseCore/FirebaseCore/Sources(勾选Recursive)$(inherited)(确保继承Pods的默认头文件路径)
5. 用Rosetta模式运行Xcode
右键Launchpad中的Xcode图标 → Get Info,勾选Open using Rosetta,重启Xcode后再尝试Debug编译。
内容的提问来源于stack exchange,提问作者Henrique Mazer
相关产品推荐
相关产品推荐

