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

Android Studio与iPhone 13模拟器调试连接中断问题求助

Flutter iOS模拟器调试连接频繁中断问题

问题现象

购置旧Mac用于Flutter iOS应用开发,新建项目在iPhone 13模拟器运行Demo时频繁崩溃,系统输出日志如下:

Launching lib/main.dart on iPhone 13 in debug mode...
Running Xcode build...
Xcode build done.                                           48.5s
Error waiting for a debug connection: The log reader failed unexpectedly
Error launching application on iPhone 13.

关闭模拟器内应用后重新打开,应用可正常运行,说明构建与代码无问题,但调试连接仍会中断。执行flutter attach时输出:

Syncing files to device iPhone 13...                               12.8s

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

💪 Running with sound null safety 💪

An Observatory debugger and profiler on iPhone 13 is available at: http://127.0.0.1:61007/KV20anKK53k=/
The Flutter DevTools debugger and profiler on iPhone 13 is available at:
http://127.0.0.1:9100?uri=http://127.0.0.1:61007/KV20anKK53k=/
Lost connection to device.

已尝试的无效操作

  • flutter clean
  • IDE执行「Invalidate caches and restart」
  • pub upgrade
  • pod update

环境信息

Flutter Doctor输出

[✓] Flutter (Channel stable, 3.0.5, on macOS 11.6.7 20G630 darwin-x64, locale en-US)
    • Flutter version 3.0.5 at /Users/karolinahagegard/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (5 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/karolinahagegard/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • 4EA7D6B9-5026-4FE8-8904-0A48B7B3253C • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 11.6.7 20G630 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 104.0.5112.79

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Mac配置信息

硬件概览

Hardware Overview:

  Model Name:   MacBook Pro
  Model Identifier: MacBookPro11,1
  Processor Name:   Dual-Core Intel Core i5
  Processor Speed:  2,6 GHz
  Number of Processors: 1
  Total Number of Cores:    2
  L2 Cache (per Core):  256 KB
  L3 Cache: 3 MB
  Hyper-Threading Technology:   Enabled
  Memory:   8 GB
  System Firmware Version:  433.120.6.0.0
  SMC Version (system): 2.16f68

系统软件概览

System Software Overview:

  System Version:   macOS 11.6.7 (20G630)
  Kernel Version:   Darwin 20.6.0
  Boot Volume:  Untitled
  Boot Mode:    Normal
  Secure Virtual Memory:    Enabled
  System Integrity Protection:  Enabled
  Time since boot:  19 days 2:45

解决方案

  • 重启设备与模拟器:长时间运行的系统可能存在资源异常,重启Mac和模拟器后再尝试调试。
  • 调低模拟器性能配置:旧Mac硬件有限,打开模拟器「Window > Show Device Window」,找到对应iPhone 13设备,进入「Settings > Advanced」,关闭「Metal API Validation」,同时降低模拟器的CPU/内存分配。
  • 延长调试超时时间:在项目ios/Runner.xcworkspace中打开Xcode,找到Runner target的「Build Settings」,搜索「DEBUG」,添加FLUTTER_DEBUG_TIMEOUT环境变量,设置值为60(单位秒),延长连接等待时长。
  • 切换Flutter通道:稳定版3.0.5可能存在旧硬件+旧Xcode的兼容性问题,执行flutter channel beta、flutter upgrade切换到beta通道测试。
  • 重置模拟器:打开模拟器「Device > Erase All Content and Settings」,重置后重新安装应用。
  • 临时关闭SIP测试:注意此操作会降低系统安全性,仅作测试用。重启Mac进入恢复模式,打开终端执行csrutil disable,重启后尝试调试,问题解决后可执行csrutil enable重新开启。

内容的提问来源于stack exchange,提问作者Karolina Hagegård

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 15:15:32