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

iOS模拟器无法启动Flutter应用调试问题求助

Flutter iOS模拟器调试启动失败:FileSystemException(dart:html URI错误)

问题详情

无法在iOS模拟器中启动Flutter应用调试,已处理Podfile缺失问题,执行过以下命令但无效:

  • sudo gem install cocoapods
  • pod init
  • pod install
  • flutter clean && flutter run

具体报错信息:

FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1      asFileUri (package:vm/kernel_front_end.dart:659:37)
#2      writeDepfile (package:vm/kernel_front_end.dart:799:21)
    <asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:625:9)
    <asynchronous suspension>
#4      starter (package:frontend_server/frontend_server.dart:1451:12)
    <asynchronous suspension>
#5      main (file:///opt/s/w/ir/x/w/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:10:14)
    <asynchronous suspension>
    Failed to package /Users/rashedmq/development/playground/first_app.
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Building targets in dependency order
    warning: Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
    warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
    Result bundle written to path:
        /var/folders/vq/xkqtqsmx12l71dw9jj9c9wzw0000gn/T/flutter_tools.FjOdaq/flutter_ios_build_temp_dir7fPzMI/temporary_xcresult_bundle
Could not build the application for the simulator.
Error launching application on iPhone 14 Plus.

修复步骤

这个错的根源是项目里引入了只支持Web平台的dart:html库,但iOS模拟器属于原生平台,编译时出现冲突。试试下面这些修复步骤:

  • 检查依赖库
    打开pubspec.yaml查看依赖项,确认是否有依赖使用dart:html的包(比如部分Web专属UI组件、网络工具包)。如果需要跨平台支持,替换为Flutter官方推荐的跨平台替代包——比如用dart:io替代dart:html做文件操作,用http包替代Web专属请求库。

  • 隔离dart:html的引用
    全局搜索项目中的import 'dart:html';语句,确保这些引用仅在Web平台代码中生效,通过条件导入实现隔离:

    // 仅Web平台导入dart:html,其他平台用空文件占位
    import 'dart:html' if (dart.library.io) 'dummy_html.dart';
    

    自行创建一个空的dummy_html.dart文件,非Web平台编译时就不会触发错误。

  • 彻底清理重建项目
    执行以下命令清空缓存并重新构建:

    flutter clean
    rm -rf ios/Pods ios/Podfile.lock ios/Runner.xcworkspace
    pod install --project-directory=ios
    flutter run
    
  • 升级Flutter SDK
    尝试将Flutter更新到最新稳定版,排查是否为SDK本身的兼容性问题:

    flutter upgrade
    
  • 检查Xcode配置
    打开ios/Runner.xcworkspace,确认项目Build Settings中无错误路径配置,同时保证Runner target的Deployment Target与模拟器系统版本兼容。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 03:25:29