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

flutter build ios及Xcode构建均失败 非明确报错无法解决求助

问题根因

你日志中出现的所有警告都不会触发构建失败,真正的错误是Command PhaseScriptExecution failed with a nonzero exit code,该错误大概率是Flutter编译阶段的原生脚本报错,常见触发原因包括代码签名配置异常、flutter_stripe 1.2.0版本与Xcode 12.5的兼容性问题,或是flutter_native_splash、flutter_launcher_icons对应的原生构建脚本执行异常。

修复步骤

  • 第一步:检查Xcode签名配置
    打开项目ios/Runner.xcworkspace文件,进入Runner项目的「Signing & Capabilities」标签页,确认Release模式下的开发团队、Bundle ID配置正确,无签名相关报错。

  • 第二步:调整Podfile配置适配编译环境
    在ios/Podfile的末尾添加以下配置,避免Pods编译警告干扰错误排查,同时统一依赖的最低系统版本:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
      config.build_settings['SWIFT_SUPPRESS_WARNINGS'] = 'YES'
      config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = 'YES'
    end
  end
end
  • 第三步:升级Stripe相关依赖修复兼容性问题
    你当前使用的flutter_stripe: ^1.2.0是较老版本,与Xcode 12.5存在已知兼容性问题,将pubspec.yaml中的依赖升级到适配版本:
flutter_stripe: ^2.5.0

升级后执行以下命令重新构建:

flutter clean
rm -rf ios/Pods ios/Podfile.lock
flutter pub get
cd ios && pod install --repo-update
cd ..
flutter build ios --release
  • 第四步:定位具体报错脚本(若上述步骤无效)
    打开Xcode执行构建,在左侧构建日志中找到「PhaseScriptExecution」对应的执行步骤,展开完整日志即可看到具体是哪个脚本执行失败,针对性修复即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.05 13:36:00