简体   繁体   English

对于Xcode中的iOS项目,为什么测试目标默认设置为在Run上构建?

[英]For iOS projects in Xcode, why is the test target set to build by default on Run?

We were running into issues trying to add a test target to a project we inherited. 我们遇到了一些问题,试图将测试目标添加到我们继承的项目中。 The test target was working, however Running the app would always fail due to an error in the test target. 测试目标正在运行,但是由于测试目标中的错误,运行应用程序总是会失败。 We were puzzled by this and eventually found a boolean setting in the scheme that was on by default: 我们对此感到困惑,并最终在默认情况下打开的方案中找到了一个布尔设置:

在此输入图像描述

In the image, I unchecked it, but the test target for Run had a checkmark in it. 在图像中,我取消选中它,但Run的测试目标中有一个复选标记。 Removing the checkmark made everything work again. 删除复选标记使一切都恢复正常。

Why would Apple want Running your application to build your tests also? Apple为什么还要运行您的应用程序来构建测试? This makes us think there might be consequences we should be aware of. 这使我们认为可能会有我们应该注意的后果。

The problem, judging by your screen shot, is that this scheme uses the QA configuration for the Run action, whereas it uses the Debug configuration for the Test action. 从屏幕截图判断,问题在于此方案使用QA配置进行Run操作,而它使用Debug配置进行Test操作。 Thus, things work one way when you do a Test build and a different way when you do a Run build. 因此,当您执行Test构建时,事情以一种方式工作,而当您执行Run构建时,事情会以不同的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM