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

如何捕获Flutter启动iOS模拟器时的退出错误信息?

捕获iOS模拟器退出错误信息以定位Flutter应用启动故障

问题背景

调试Flutter v3.0.5版本应用时,启动iPhone XR模拟器后连接突然断开,Android Studio输出日志如下:

To see a detailed report, use the untranslated-messages-file 
option in the l10n.yaml file:
untranslated-messages-file: desiredFileName.txt
<other option>: <other selection> 


This will generate a JSON format file containing all messages that 
need to be translated.
Launching lib/main_pro.dart on iPhone Xʀ in debug mode...
Running Xcode build...
Xcode build done.                                           15.5s
Exception: Unable to launch com.earth.dolphin on 911ED020-A317-4E0E-AA48-A2369DD9EED8:
ProcessException: Process exited abnormally:
com.earth.dolphin: -1

2022-07-30 22:38:44.693 simctl[49283:1455874] apply_selection_policy_once: avoid use of removable GPUs (via com.apple.CoreSimulator.simctl:GPUSelectionPolicy->avoidRemovable)
An error was encountered processing the command (domain=FBSOpenApplicationServiceErrorDomain, code=1):
The request to open "com.earth.dolphin" failed.
The request was denied by service delegate (SBMainWorkspace).
Underlying error (domain=FBProcessExit, code=128):
    The operation couldn’t be completed. The process exited.
    The process exited.
  Command: /usr/bin/arch -arm64e xcrun simctl launch 911ED020-A317-4E0E-AA48-A2369DD9EED8 com.earth.dolphin --enable-dart-profiling --enable-checked-mode --verify-entry-points --start-paused --observatory-port=0
Error launching application on iPhone Xʀ.

使用Xcode调试时仅提示:

Command PhaseScriptExecution failed with a nonzero exit code

无法明确应用在模拟器中退出的具体原因,可通过以下方式捕获详细错误信息:

捕获错误信息的方法

1. 查看模拟器系统日志

  • 打开控制台.app(Finder中前往「应用程序/实用工具」找到)
  • 在左侧设备列表中选择对应的iPhone XR模拟器
  • 启动应用,过滤日志关键词:com.earth.dolphin(你的应用Bundle ID)或Exit,查看应用退出时的详细堆栈和错误提示

2. 通过simctl获取应用崩溃报告

  • 从Android Studio日志中提取模拟器UDID(示例中为911ED020-A317-4E0E-AA48-A2369DD9EED8)
  • 打开终端执行命令,查看最近10分钟内目标应用的日志:
    xcrun simctl spawn <模拟器UDID> log show --predicate 'processImagePath contains "com.earth.dolphin"' --style compact --last 10m
    

3. 查看Xcode Build Phases详细日志

  • 在Xcode中打开项目的ios目录
  • 选择iPhone XR模拟器为目标设备,点击「Build」
  • 当出现Command PhaseScriptExecution failed错误时,点击错误行右侧的展开箭头,查看脚本执行的具体失败原因(如Flutter脚本错误、依赖缺失等)

4. 检查模拟器崩溃报告文件

  • 模拟器崩溃报告存储路径:
    ~/Library/Logs/DiagnosticReports/
    
  • 找到以应用Bundle ID开头、后缀为.crash的文件,用文本编辑器打开查看详细崩溃堆栈,定位代码层面问题

5. 启用Flutter详细日志

  • 在终端执行带详细日志参数的启动命令:
    flutter run -d <模拟器UDID> --verbose
    
  • 该命令会输出Flutter启动全流程的细节日志,包括与iOS模拟器交互的环节,有助于定位启动失败节点

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 16:16:03