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
相关推荐
恋猫de小郭18 小时前
你还用 IDE 吗? AI 狂欢时代下 Cursor 慌了, JetBrains 等 IDE 的未来是什么?
前端·flutter·ai编程
TT_Close1 天前
🐟 发布中心进度同步:8 个商店的上传功能开发完毕,正抓紧测试
flutter·npm·visual studio code
RaidenLiu2 天前
Flutter Platform Channel 底层架构解析 —— 从 BinaryMessenger 到跨平台消息通信机制
前端·flutter·前端框架
开心就好20252 天前
iOS App 安全加固流程记录,代码、资源与安装包保护
后端·ios
开心就好20252 天前
iOS App 性能测试工具怎么选?使用克魔助手(Keymob)结合 Instruments 完成
后端·ios
鹏多多2 天前
Flutter使用screenshot进行截屏和截长图以及分享保存的全流程指南
android·前端·flutter
恋猫de小郭2 天前
什么 AI 写 Android 最好用?官方做了一个基准测试排名
android·前端·flutter
zhongjiahao3 天前
面试常问的 RunLoop,到底在Loop什么?
ios
勤劳打代码3 天前
Flutter 架构日记 — 状态管理
flutter·架构·前端框架
wvy4 天前
iOS 26手势返回到根页面时TabBar的动效问题
ios