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相关配置
- 把
use_frameworks!改成静态链接模式,Firebase现在更推荐这种方式:use_frameworks! :linkage => :static - 在
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
相关产品推荐
相关产品推荐

