xcodebuild: error: Failed to build workspace. Reason: A build only device cannot be used to run this target

xcodebuild: error: Failed to build workspace. Reason: A build only device cannot be used to run this target

我正在尝试使用命令行在设备 (iPhone) 上构建和测试:

xcodebuild  \
    -workspace MyApp.xcworkspace \
    -scheme MyApp \
    -destination 'generic/platform=iOS,id=iPhoneUUID' \
    clean test

但是我收到这个错误:

xcodebuild: error: Failed to build workspace MyApp with scheme MyApp.
    Reason: A build only device cannot be used to run this target.

你们知道我为什么会收到这个错误吗?

非常感谢任何帮助。

删除 -destination 值中的 generic 部分。否则 Xcode 不会尝试为您的设备构建,而是为通用构建设备:

xcodebuild  \
    -workspace MyApp.xcworkspace \
    -scheme MyApp \
    -destination 'platform=iOS,id=iPhoneUUID' \
    clean test