You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter切换Xcode配置后模拟器启动失败,报xcodebuild目标匹配错误

Flutter模拟器启动报错:无法找到匹配的目标设备ID

问题详情

原本运行正常的Flutter应用,调整Xcode配置为Release模式后,仅能通过flutter run --profile命令在真机正常启动。尝试启动模拟器时收到报错:

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
            { id:C80BB36C-4498-4641-92D8-F69090A819A9 }

执行flutter run --profile连接真机时,设备列表能显示iPhone 14(对应上述ID),但Android Studio中选择该iPhone 14模拟器启动时,无法找到对应目标。flutter doctor检测无异常:

[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F82 darwin-arm64, locale fr-BE)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

当前使用Xcode 14.3.1版本。

解决方案

1. 恢复Xcode Scheme的Debug配置

  • 打开项目ios目录下的Runner.xcworkspace(注意是xcworkspace而非xcodeproj)
  • 顶部菜单栏点击Product > Scheme > Manage Schemes
  • 选中你的应用Scheme,点击Edit,切换到Run标签页
  • 将Build Configuration从Release改回Debug(Release模式默认不兼容模拟器架构)
  • 关闭Xcode,终端执行flutter clean后重新构建项目

2. 重置模拟器并清除缓存

  • 终端执行flutter devices,确认模拟器是否被识别
  • 若模拟器未显示,打开Xcode的Window > Devices and Simulators,找到目标iPhone 14模拟器,删除后重新创建一个
  • 执行以下命令彻底清除缓存:
    flutter clean
    rm -rf ios/Pods ios/Podfile.lock
    cd ios && pod install && cd ..
    

3. 直接指定模拟器运行

  • 终端执行flutter emulators,获取可用模拟器的ID或名称
  • 先启动模拟器:flutter emulators --launch <模拟器ID/名称>
  • 再执行flutter run -d <模拟器ID/名称>,强制指定该模拟器启动应用

4. 刷新Android Studio设备列表

  • 打开Android Studio的Tools > Device Manager,点击右上角的刷新按钮
  • 若仍不显示模拟器,重启Android Studio后再次检查
  • 确认Preferences > Languages & Frameworks > Flutter中的SDK路径配置正确

内容的提问来源于stack exchange,提问作者Bernard

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 03:32:26