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

Flutter应用无法在iOS真机运行,模拟器及Android端正常求助

Flutter iOS真机启动卡启动页+VM Service连接失败解决办法

问题现象

  • Android真机/模拟器、iOS模拟器运行正常
  • iOS真机启动后仅停留在启动页,无后续反应,无直接报错
  • VS Code控制台持续出现VM Service连接拒绝日志:
Connecting to the VM Service is taking longer than expected...
Still attempting to connect to the VM Service...
If you do NOT see the Flutter application running, it might have crashed. The device logs (e.g. from adb or XCode) might have more details.
If you do see the Flutter application running on the device, try re-running with --host-vmservice-port to use a specific port known to be available.
Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 52448
This was attempt #50. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 52559
This was attempt #100. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 52660
This was attempt #150. Will retry in 0:00:01.600000.

排查与解决步骤

1. 检查网络与端口权限

  • 确保手机和电脑在同一Wi-Fi网络,关闭电脑防火墙/安全软件,避免拦截VM Service端口
  • 改用USB线连接真机调试,排除Wi-Fi网络端口映射问题

2. 清理缓存与重建依赖

  • 执行Flutter缓存清理:
    flutter clean
    
  • 进入iOS目录清理Pod依赖并重新安装:
    cd ios
    rm -rf Pods Podfile.lock
    pod install
    cd ..
    

3. 重置真机调试会话

  • 断开手机连接,关闭App并重启手机
  • 重新连接后,在Xcode中打开项目ios目录,执行Product > Clean Build Folder,再重新运行

4. 指定固定VM Service端口

  • 运行时指定固定端口,避免自动分配端口被占用:
    flutter run --host-vmservice-port 8888
    

5. 查看Xcode设备日志找根因

  • 打开Xcode,选择Window > Devices and Simulators,选中真机后点击View Device Logs,查看App启动时的崩溃日志或错误信息(比如权限缺失、第三方SDK兼容问题)

6. 验证Flutter环境与依赖版本

  • 升级Flutter到最新稳定版:
    flutter upgrade
    
  • 检查项目中iOS相关插件版本,确保与当前Flutter版本兼容

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 21:36:29