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
相关推荐
weixin_5633714712 小时前
Android Studio 2024 版 Device Explorer 打开方法
android·ide·android studio
瓦瓦gogo13 小时前
第一次了解 iOS 开发:从 Swift、SwiftUI 到公共组件
ios·swiftui·swift
洞见前行15 小时前
点击图标到内容出现,你的 App 在这几秒里做了什么:Android 冷启动全链路优化实战
android·性能优化·android studio
Liben16 小时前
Weex开发踩坑记录
android·前端·ios
season_zhu18 小时前
Skills For Real Engineers 系列之三:需求聊清楚了,怎么一步步走主流程,做到交付?
ios·ai编程
茶底世界之下19 小时前
窗边花瓶太暗?用 Awaking 看提亮室内的代价
ios
2501_9159090619 小时前
Windows 上用 VS Code 调试 iPhone 真机 App,KXBuild 断点、崩溃定位实操
ide·windows·vscode·ios·iphone·个人开发·敏捷流程
恋猫de小郭20 小时前
最近 Android 有什么更新:Android Dev Summit 2026 技术解读
android·前端·flutter
好的佩奇1 天前
Dart 之类修饰符
android·flutter·dart
2501_916007471 天前
抓包工具功能对比,TraceEagle、Charles、Fiddler、Wireshark、mitmproxy 差别
前端·网络协议·ios·adb·https·fiddler·wireshark