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

Flutter开发:Mac下pod install报错及卡住问题求助

Flutter项目M2 Mac上pod install问题解决指南

问题回顾

在M2芯片Mac上导入Flutter项目后,执行pod install卡住;删除Podfile后执行命令提示No Podfile found in the project directory;修改Xcode Runner target版本为8,但项目要求最低版本11。

解决步骤

1. 恢复并修正Podfile

  • 将你提供的Podfile内容复制到项目的ios目录下,命名为Podfile(无后缀)。
  • 编辑Podfile,把注释行# platform :ios, '8.0'修改为:
    platform :ios, '11.0'
    
    确保与项目要求的最低iOS版本一致。

2. 清理缓存并重新执行pod install

打开终端,按以下顺序执行命令:

  • 进入项目的ios目录:
    cd 你的项目路径/ios
    
  • 清理现有Pod相关文件:
    pod deintegrate
    rm -rf Pods
    rm Podfile.lock
    flutter clean
    flutter pub get
    
  • 针对M2芯片的Rosetta兼容处理:
    右键终端图标→显示简介→勾选「使用Rosetta打开」,重启终端后执行:
    pod install
    
  • 若仍卡住,可切换国内镜像源:在Podfile最顶部添加(二选一):
    source 'https://mirrors.tuna.tsinghua.edu.cn/git/cocoapods/specs.git'
    # 或官方源:source 'https://cdn.cocoapods.org/'
    

3. 同步Xcode版本配置

  • 打开ios目录下的Runner.xcworkspace(不要打开Runner.xcodeproj)。
  • 选中Runner target,切换到General标签,在「Deployment Info」中把iOS版本设为11.0。
  • 进入Build Settings,搜索「iOS Deployment Target」,确保所有target的版本都设置为11.0。

内容的提问来源于stack exchange,提问作者Gökçenaz Akyol

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 04:30:30