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

Flutter iOS编译失败:Command PhaseScriptExecution非零退出码求助

解决Flutter iOS构建失败(找不到CrashReporter .o文件)的方案

排查CrashReporter依赖来源

  • 检查项目pubspec.yaml,确认是否有第三方包引入了CrashReporter相关依赖(如崩溃上报类SDK),临时注释该包后重新构建,验证是否为包的适配问题。
  • 若锁定问题包,查看其官方仓库Issue,确认是否存在M1+Xcode14的适配bug,尝试升级到最新版本或替换替代包。

Xcode架构与构建设置调整

  • 打开iOS项目的Runner.xcworkspace,进入Runner target的Build Settings:
    1. 将Architectures设置为Standard Architectures (arm64, x86_64),确保同时支持M1本地架构和模拟器架构。
    2. 找到Build Options下的Validate Workspace,设置为Yes后重新构建。
    3. 检查Other Linker Flags,若存在多余的-lCrashReporter类引用,直接移除。

彻底清理与重建

  • 执行全套清理命令:
    flutter clean
    rm -rf ios/Pods
    rm ios/Podfile.lock
    rm -rf ~/Library/Developer/Xcode/DerivedData
    cd ios && pod deintegrate && pod install
    
  • 重启Xcode和Mac,清除系统缓存残留。

M1设备专属适配

  • 开启Xcode的Rosetta模式:右键应用列表中的Xcode,选择「显示简介」,勾选「使用Rosetta打开」,重启Xcode后重新构建。
  • 在Podfile顶部添加M1适配配置,再执行pod install:
    platform :ios, '11.0'
    installer.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
    installer.user_project_targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
      end
    end
    

手动引入库的完整性检查

  • 若项目手动添加过CrashReporter静态库/.framework文件,用以下命令检查架构完整性:
    lipo -info /path/to/CrashReporter.framework/CrashReporter
    
    若缺少arm64架构,重新获取适配M1的版本,或改用CocoaPods管理该依赖。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 20:24:59