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

Flutter项目运行pod install命令报错,已尝试多种常规方案仍未解决

Flutter项目pod install报错修复步骤

1. 统一iOS部署目标版本

  • 打开Xcode加载ios/Runner.xcodeproj,将Runner目标的iOS Deployment Target调整为12.0及以上版本
  • 修改ios/Podfile文件,将顶部的platform :ios, 'x.x'配置修改为和项目一致的版本,例如platform :ios, '12.0',确保注释掉的示例配置也同步调整

2. 全量清理依赖缓存后重新安装

依次执行以下命令:

flutter clean
rm -rf ios/Pods ios/Podfile.lock ios/Runner.xcworkspace
rm -rf ~/Library/Caches/CocoaPods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
flutter pub get
cd ios
pod install --repo-update

3. Apple Silicon芯片设备额外适配

如果你使用的是M系列芯片的Mac,执行以下命令兼容x86架构依赖:

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install

4. 强制兼容配置

如果仍存在架构或版本兼容报错,在ios/Podfile的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'] = '12.0'
      # 排除模拟器不兼容的架构
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"
    end
  end
end

修改完成后重新执行pod install即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.06 15:15:02