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

Flutter升级至3.10.x后iOS端编译失败问题求助

Flutter 3.10.x iOS编译失败(Switch Case穿透错误)解决方案

问题

升级Flutter到3.10.x后,所有iOS项目(包括新建项目)编译失败,Flutter Doctor检测无异常,降级到3.7版本可正常运行。核心报错为xcode_backend.dart中的Switch Case未处理穿透问题。

报错详情

Failed to build iOS app
Error output from Xcode build:
↳
    2023-07-06 13:02:56.076 xcodebuild[22219:218821] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
2
    { platform:iOS Simulator, id:800166DA-CB72-4A20-BE70-7D17A091A28D, OS:16.4, name:iPhone 14 }
    ** BUILD FAILED **
Xcode's output:
↳
    Writing result bundle at path:      /var/folders/cn/qp_12tv102j5blhmp_p43zn80000gn/T/flutter_tools.4acIQd/flutter_ios_build_temp_dirzyOVmy/temporary_xcresult_bundle
../../../../development/flutter/packages/flutter_tools/bin/xcode_backend.dart:50:7: Error: Switch case may fall through to the next case.
          case 'build':
          ^
../../../../development/flutter/packages/flutter_tools/bin/xcode_backend.dart:55:7: Error: Switch case may fall through to the next case.
          case 'embed':
          ^
../../../../development/flutter/packages/flutter_tools/bin/xcode_backend.dart:57:7: Error: Switch case may fall through to the next case.
          case 'embed_and_thin':
          ^
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Building targets in dependency order
    note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
    note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
    Result bundle written to path:
        /var/folders/cn/qp_12tv102j5blhmp_p43zn80000gn/T/flutter_tools.4acIQd/flutter_ios_build_temp_dirzyOVmy/temporary_xcresult_bundle
Could not build the application for the simulator.
Error launching application on iPhone 14.
Exited

解决步骤

1. 修复Flutter工具源码中的Switch Case

找到Flutter安装目录下的packages/flutter_tools/bin/xcode_backend.dart文件,定位到报错的三个case:

  • 在case 'build':、case 'embed':、case 'embed_and_thin':代码块末尾添加break;语句,阻止case穿透。

修改示例:

case 'build':
  await buildPhase();
  break; // 添加这行
case 'embed':
  await embedPhase();
  break; // 添加这行
case 'embed_and_thin':
  await embedAndThinPhase();
  break; // 添加这行

2. 清理并重建项目

执行以下命令清理缓存,重新安装依赖:

flutter clean
cd ios
pod deintegrate
pod install
cd ..
flutter run

3. 升级Dart版本(可选)

确保Dart版本与Flutter 3.10.x兼容:

flutter upgrade --dart

4. 临时降级(备选)

若上述方法无效,可暂时降级到Flutter 3.7.x:

flutter downgrade 3.7.12

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 08:44:56