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

Flutter iOS版本构建失败:Xcode报“Multiple commands produce”错误

Flutter iOS构建失败:Multiple commands produce 框架文件错误(Firebase迁移后)

问题重现

迁移至Firebase后,Android构建正常,但iOS执行flutter build ios时出现多个框架重复生成错误,包括FirebaseFirestoreInternal.framework、grpcpp.framework等,常规清理缓存(flutter clean、pod cache clean等)操作无效,Copy Bundle Resources中无重复文件。

解决方案

1. 统一Firebase依赖版本

不同Firebase库可能依赖了不同版本的底层框架(如grpc、absl),导致冲突:

  • 打开pubspec.yaml,确保所有firebase_*开头的依赖使用相同大版本,例如:
    dependencies:
      firebase_core: ^2.27.0
      cloud_firestore: ^4.15.0
      firebase_auth: ^4.17.0
    
  • 执行命令更新依赖:
    flutter pub get
    cd ios && pod update
    

2. 调整Xcode Build Settings

  • 打开ios/Runner.xcworkspace,选中Runner target
  • 在Build Settings中搜索并修改以下选项:
    • 设置Build Libraries for Distribution为YES
    • 设置Parallelize Build为NO
  • 清理后重新构建:flutter clean && flutter build ios

3. 检查并移除重复框架引用

  • 在Xcode的Runner target中,进入Frameworks, Libraries, and Embedded Content
  • 检查是否存在重复的FirebaseFirestoreInternal、grpcpp等框架,若有则移除重复项
  • 确认Podfile中没有手动添加的与Firebase底层相关的pod(如grpc、absl),避免和Flutter自动引入的冲突

4. 修改CocoaPods链接方式为静态

静态链接可避免动态框架重复生成问题:

  • 打开ios/Podfile,将顶部的use_frameworks!替换为:
    use_frameworks! :linkage => :static
    
  • 执行彻底清理和重新安装:
    flutter clean
    cd ios && rm -rf Pods Podfile.lock && pod cache clean --all && pod install
    
  • 重新构建iOS项目

5. 升级Flutter与Firebase依赖

部分旧版本Flutter或Firebase依赖存在已知的iOS构建冲突:

  • 升级Flutter到最新稳定版:
    flutter upgrade
    
  • 更新所有Firebase依赖到最新兼容版本:
    flutter pub upgrade firebase_core cloud_firestore firebase_auth
    
  • 重新执行pod安装和构建

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 07:53:22