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
相关推荐
好的佩奇9 小时前
蓝牙之设备角色与连接
android·flutter·蓝牙
茶底世界之下20 小时前
雨后的黄电车:用 Awaking 给灰色街景定一个主角
ios·app·产品
恋猫de小郭21 小时前
iOS for Web ,把原生 iOS App 跑到进浏览器里面,倒反天罡
android·前端·ios
SoaringHeart1 天前
Flutter最佳实践:用 flutter_html 渲染富文本
前端·flutter
00后程序员1 天前
iOS 实时活动怎么开发,Windows 上用 KXBuild 和 ActivityKit 写灵动岛
后端·ios
iReaShare2 天前
如何在没有 Wi-Fi 的情况下备份 iPhone
ios
恋猫de小郭2 天前
Flutter 3.50.0 Release 的第一个崩溃,修好了,还没 hotfix
android·前端·flutter
CocoaKier2 天前
苹果开发者注意,请在2027年1月31日前完成合规验证,否则中国区可能下架
ios·aigc·apple
二流小码农3 天前
鸿蒙开发:证书只能创建3个,第4个应用怎么办
android·ios·harmonyos
bcbnb3 天前
Windows 上 iOS 开发接 CI,KXBuild 自托管 runner 出签名 ipa
后端·ios