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

Codemagic构建Flutter iOS应用报错:Module 'cloud_firestore'未找到

解决Codemagic构建Flutter iOS应用时cloud_firestore模块找不到的问题

试试下面这些针对性的解决方案:

  • 彻底清理依赖缓存并重新生成
    本地先执行以下命令,确保依赖状态干净:

    flutter clean
    flutter pub get
    cd ios
    pod deintegrate
    pod repo update
    pod install --repo-update
    

    之后把更新后的Podfile.lock和ios/Flutter目录下的变更提交到Git,保证Codemagic拉取的是最新的依赖配置。

  • 调整Codemagic构建脚本,强制重新拉取依赖
    在Codemagic的「构建前脚本」里添加:

    flutter clean
    flutter pub get
    cd ios
    rm -rf Pods Podfile.lock
    pod setup
    pod install --repo-update
    

    跳过本地缓存,让Codemagic环境重新下载所有Pod依赖,避免环境差异导致的问题。

  • 修改Podfile的Firebase相关配置

    1. 把use_frameworks!改成静态链接模式,Firebase现在更推荐这种方式:
      use_frameworks! :linkage => :static
      
    2. 在post_install块里添加额外配置,确保所有目标的部署版本和编译设置统一:
      post_install do |installer|
        installer.pods_project.targets.each do |target|
          flutter_additional_ios_build_settings(target)
          target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
            config.build_settings['ENABLE_BITCODE'] = 'NO'
          end
        end
      end
      
  • 检查Codemagic的构建环境版本
    在Codemagic的构建配置里,选择Xcode 14及以上版本(确保支持iOS 11.0+),同时确认iOS SDK版本符合要求。可以在构建脚本里加一行xcodebuild -showsdks查看当前环境的可用SDK。

  • 验证依赖版本兼容性
    打开pubspec.yaml,确保cloud_firestore的版本和你用的Flutter稳定版兼容,比如用最新的稳定版依赖:

    dependencies:
      cloud_firestore: ^4.15.0 # 可根据Flutter版本调整为对应兼容版本
    

    执行flutter pub outdated检查有没有不兼容的依赖,及时更新。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 14:50:10