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

添加Firebase依赖后Flutter iOS模拟器构建失败求助

解决Flutter添加Firebase依赖后iOS模拟器构建失败(x86_64符号缺失)

我之前碰到过一模一样的问题,这种Undefined symbols for architecture x86_64的链接错误,大多是Firebase依赖版本兼容问题、iOS构建缓存残留,或者Podfile配置不符合当前Firebase要求导致的。给你几个一步步解决的方案:

1. 升级Firebase依赖到兼容版本

你当前使用的firebase_core: ^0.4.5版本比较老旧,和Flutter 2.7.x的兼容性可能存在问题。先更新pubspec.yaml里的Firebase依赖:

dependencies:
  # 其他依赖保持不变
  firebase_core: ^1.10.0 # 选择适配Flutter 2.7.x的稳定版本

更新后执行:

flutter pub get

2. 彻底清理构建缓存并重新安装Pods

残留的缓存经常会导致依赖冲突,执行以下命令:

# 清理Flutter项目缓存
flutter clean

# 进入iOS目录,删除旧的Pods和锁文件
cd ios
rm -rf Pods Podfile.lock

# 更新CocoaPods仓库并重新安装
pod repo update
pod install

# 返回项目根目录
cd ..

3. 调整Podfile配置

你的Podfile有几个需要修改的点:

  • 明确指定iOS最低版本为10.0(Firebase现在要求最低iOS 10.0)
  • 修改use_frameworks!为静态链接模式,适配Firebase的依赖链
  • 优化Build Settings确保模拟器架构支持

修改后的Podfile关键部分:

# 取消注释并修改iOS版本
platform :ios, '10.0'

# ... 其他代码保持不变

target 'Runner' do
  # 修改为静态链接的frameworks
  use_frameworks! :linkage => :static
  use_modular_headers!

  # ... 其他代码保持不变
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    # 添加Flutter官方推荐的配置
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
      # 强制模拟器使用x86_64架构
      config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
    end
  end
end

修改后重新执行cd ios && pod install。

4. 验证Xcode架构设置(可选)

如果以上步骤还没解决,打开ios/Runner.xcworkspace:

  • 选择Runner target,进入Build Settings
  • 找到Architectures选项,确保Architectures设置为Standard Architectures (arm64, x86_64)
  • 确认Valid Architectures包含x86_64(Xcode 12+可能默认隐藏,可通过右键选择"Show Hidden Settings"查看)

完成以上步骤后,重新尝试构建项目,应该就能解决x86_64符号缺失的问题了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 14:57:33