Xcode 无法将测试目标添加到现有的 swift 项目 - 要测试的目标是灰色的

Xcode 无法将测试目标添加到现有的 swift 项目 - 要测试的目标是灰色的

问题描述:

我有一个现有项目,我正在尝试向其中添加单元测试.我使用的是 Xcode 10.1,项目完全使用 Swift.

I have an existing project that I am trying to add unit tests to. I'm on Xcode 10.1 and project is purely in Swift.

我首先点击新目标..."在第一个对话框中,我可以选择项目,但要测试的目标"对话框是灰色的.

I start by clicking on "New Target..." In the first dialog I am able to choose the project but the dialog box for "Target to be tested" is grayed out.

我尝试在没有选择的情况下继续添加测试目标,这导致我的测试包无法找到我现有的类 - 没有这样的模块错误"

I have tried to go ahead and add the test target without choosing and this results in my test bundle not being able to find my existing classes - "No such Module error"

这是添加测试包的对话框:

Here is the dialog for adding the test bundle:

不知道我做错了什么来阻止这个选择

Not sure what I'm doing wrong to prevent the this selection

感谢您的帮助!

在 Xcode 10.2.1 中,打开你的项目,点击里面有破折号的菱形:

In Xcode 10.2.1, with your project open, click on the diamond with a dash in it:

然后在项目窗口的左下方单击+"并选择New Unit Test Target".

Then down at the bottom left of the project window click on the '+' and select "New Unit Test Target".