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

执行xcodebuild命令报错:无法在Xcode项目中找到指定目标设备

解决xcodebuild无法识别已连接iOS设备的问题

问题详情

执行以下xcodebuild命令时触发报错:

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test

报错内容:

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ id: }

The requested device could not be found because no available devices matched the request.

Available destinations for the "WebDriverAgentRunner" scheme:
    { platform:macOS, arch:x86_64, variant:Mac Catalyst, id:00B9EE23-6C05-53C6-8661-775B8F1E5F68 }
    { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
    { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
    { platform:macOS, variant:Mac Catalyst, name:Any Mac }
    { platform:iOS, id:b8f8c7bb18de6b9fa6793f33c4f5604e7cf0763e, name:Vandana’s iPhone }
    ...(其余模拟器设备条目略)

当前环境:

  • macOS: Monterey
  • Xcode: 14.2
  • iOS设备系统版本: 15.7.5

修复步骤

按以下顺序尝试解决:

1. 校验UDID输入准确性

从可用设备列表中可见,已连接设备的正确UDID为 b8f8c7bb18de6b9fa6793f33c4f5604e7cf0763e,确保命令中的<udid>完全替换为该值,无拼写错误或多余符号。

2. 完成设备信任与调试授权

  • 连接iOS设备到Mac,打开设备「设置」→「通用」→「VPN与设备管理」,找到Xcode对应的开发者证书,点击「信任」。
  • 打开Xcode的「Window」→「Devices and Simulators」面板,选中已连接设备,确认设备状态为「已准备就绪」,若弹出授权提示,点击「允许」。

3. 补充Xcode的旧版iOS支持文件

Xcode 14.2默认最高支持iOS 16.2,你的设备为iOS 15.7.5,可能存在兼容性缺失:

  • 打开Xcode「Preferences」→「Components」,检查是否有iOS 15.7的模拟器支持包,如有则安装;若没有,重新下载完整版本的Xcode 14.2(确保包含旧版iOS支持组件)。

4. 清理Xcode缓存并重启

  • 关闭Xcode,执行以下命令清理缓存:
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode
  • 重启Mac和iOS设备,重新连接后再次尝试执行命令。

5. 改用设备名称指定目标

若UDID方式仍失败,尝试用设备名称替换UDID:

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'name=Vandana’s iPhone' test

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 12:02:52