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

MacOS模拟器中Flutter克隆项目无法运行问题求助

解决方案

1. 正确适配ARM Mac架构安装依赖

你需要严格按照报错提示的架构要求执行安装,之前的操作可能未彻底生效,按以下步骤重新操作:

  • 先卸载现有相关依赖:
    sudo gem uninstall ffi cocoapods
    
  • 以x86_64架构安装ffi:
    arch -x86_64 sudo gem install ffi
    
  • 同样以x86_64架构安装CocoaPods:
    arch -x86_64 sudo gem install cocoapods
    
  • 进入项目的ios目录,指定架构执行pod安装:
    cd ios
    arch -x86_64 pod install
    

2. 修复项目Podfile的ARM兼容配置

克隆的项目大概率缺少ARM Mac的适配配置,在项目ios/Podfile开头添加以下内容(注意匹配项目最低iOS版本):

platform :ios, '14.0' # 根据项目实际最低版本调整
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    # 强制模拟器使用x86_64架构
    target.build_configurations.each do |config|
      config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
    end
  end
end

保存后重新执行arch -x86_64 pod install

3. 清除缓存重新构建

  • 清除Flutter项目缓存:
    flutter clean
    
  • 进入ios目录清理Pod相关缓存:
    cd ios
    pod deintegrate
    pod cache clean --all
    
  • 重新获取依赖并构建:
    flutter pub get
    arch -x86_64 pod install
    

4. 确认终端架构

在Android Studio的终端中执行以下命令检查当前架构:

arch

如果输出为arm64,先切换到x86_64架构再执行后续命令:

arch -x86_64 zsh # 若使用bash则替换为bash

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 18:26:17