Flutter iOS 真机部署异常经验(Android Studio 提示无法运行,但 Xcode 可正常运行)

症状:

  • 在 Android Studio 或 flutter run 时出现:

    Could not run build/ios/iphoneos/Runner.app on <DEVICE_ID>.
    Try launching Xcode and selecting "Product > Run" to fix the problem:
    open ios/Runner.xcworkspace

    Error launching application on <DEVICE_NAME>.

  • 但是在 Xcode 里直接 Product > Run 可以正常安装并启动 App

  • 这个问题同时伴随 Flutter 日志无法显示、热重载不可用(如果用 VS Code 或 flutter run attach)

根本原因:

  • /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ 目录下 缺少真机 iOS 版本对应的 DeviceSupport 文件
  • Flutter CLI / Android Studio 在尝试真机部署时依赖该文件来 attach 调试服务
  • 缺失时会导致 Android Studio 提示安装失败,但 Xcode 直接 run 会成功(因为 Xcode 内部可以处理调试安装)

解决方案:

  1. 下载真机对应 iOS 版本的 DeviceSupport 文件,例如 14.8:

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/

  2. 重启 Xcode 和真机

  3. 再次在 Android Studio 或命令行执行 flutter run

  4. 真机部署正常,同时日志和热重载功能也恢复

效果示例:

复制代码
Launching lib/main.dart on longforus的iPhone8 in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: LK85L26J8M
Running Xcode build...
Xcode build done.                                           11.2s
Installing and launching...
The Dart VM Service was not discovered after 30 seconds. This is taking much longer than expected...
Debug service listening on ws://127.0.0.1:49866/PAclZr3UDQc=/ws
Syncing files to device longforus的iPhone8...
[GETX] Instance "DBService" has been created
[GETX] Instance "DBService" has been initialized
[GETX] Instance "GlobalService" has been created
[GETX] Instance "GlobalService" has been initialized
相关推荐
harder32121 小时前
RMP模式的创新突破
开发语言·学习·ios·swift·策略模式
maaath1 天前
【maaath】Flutter for OpenHarmony 跨平台工程集成密码加密能力
flutter·华为·harmonyos
yeziyfx1 天前
Flutter 纯色矩形
flutter
liulian09161 天前
Flutter for OpenHarmony 混合开发实践:用户反馈功能的实现与适配
flutter·华为·学习方法·harmonyos
Hello__77771 天前
开源鸿蒙 Flutter 实战|文章分类标签功能全流程实现
flutter·开源·harmonyos
xiaoyan20151 天前
2026爆肝!Flutter3.41纯手撸微信聊天APP原生应用
android·flutter·dart
程序员老刘1 天前
当全网都在喊“程序员要被AI取代了”,Flutter给了另一种答案
flutter·ai编程·客户端
国医中兴1 天前
Flutter 三方库 nhost_graphql_adapter 的鸿蒙化适配指南 - 云端数据实时对齐、GraphQL 架构实战、鸿蒙级全栈交互专家
flutter·harmonyos·graphql
for_ever_love__1 天前
UI学习:UITableView的基本操作及折叠cell
学习·ui·ios
IntMainJhy1 天前
Flutter 三方库 get_it + flutter_bloc 的鸿蒙化适配与实战指南
flutter·华为·harmonyos