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
相关推荐
梦想的颜色11 小时前
AI 时代小白 VibeCoding 做 APP:UniApp(含 Uni‑X)、Flutter 与 React Native+Expo全维度技术选型对比指南
flutter·react native·app·uniapp·vibecoding·unippx·app产品
人月神话Lee13 小时前
我做了个不要账号、不要定位权限的旅行 App,聊聊那些「不做」的决定
ios·ai编程·产品
坚果的博客13 小时前
Flutter-OH 3.44.9-dev 悄然上线|首个 OpenHarmony Canary 预览版上线
flutter
大龄秃头程序员14 小时前
Flutter 动画随笔:业务里真正高频的几类控件
flutter
天空之城--15 小时前
Android Flutter行业最新动态与实用参考(2026年8月第2周)
android·flutter
恋猫de小郭15 小时前
Flutter 3.47 发布,快来看看有什么更新吧
android·前端·flutter
大龄秃头程序员1 天前
一次 Flutter 动画 Demo 的整理与复盘
flutter
2501_916007471 天前
Bundle ID 注册与管理 App ID 创建指南 命名规则 权限开关与删除注意事项
android·ios·小程序·https·uni-app·iphone·webview
AlexMaybeBot1 天前
躺在沙发上开发 Openclaw 的移动端APP
前端·flutter