Xcode 14中xcodebuild test报错:无法找到DoSomethingElseTests测试主机
解决xcodebuild测试报错"Could not find test host"的方法
检查TEST_HOST配置的正确性
打开项目的DoSomethingElseTests测试目标的Build Settings,搜索TEST_HOST,确认其值在DoSomethingElse配置下正确指向主应用的可执行文件,格式通常为$(BUILT_PRODUCTS_DIR)/DoSomethingElse.app/DoSomethingElse。很多时候IDE默认用Debug配置运行测试,而你命令里指定了自定义的DoSomethingElse配置,可能该配置下TEST_HOST未正确设置。验证scheme与配置的匹配性
打开Xcode的Edit Scheme窗口,进入Test标签页的Info选项,确认DoSomethingElseTests目标使用的Build Configuration和你命令中指定的DoSomethingElse一致,同时确保scheme包含该测试目标。清理构建缓存后重试
先执行清理命令清除旧的构建产物:xcodebuild clean -configuration DoSomethingElse -project DoSomethingElse.xcodeproj之后再重新运行你的测试命令,避免缓存导致的路径异常。
显式指定测试目标
如果以上方法无效,尝试在命令中直接指定测试目标:xcodebuild -sdk iphonesimulator -configuration DoSomethingElse -project DoSomethingElse.xcodeproj -scheme DoSomethingElse -destination "platform=iOS Simulator,name=iPhone 8 Plus" test -test-target DoSomethingElseTests
内容的提问来源于stack exchange,提问作者user2924482
相关产品推荐
相关产品推荐

