Xcode 无法将测试目标添加到现有的 swift 项目 - 要测试的目标是灰色的 [英] Xcode Unable to add test target to existing swift project - Target to be tested is grayed out

查看:39
本文介绍了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".

这篇关于Xcode 无法将测试目标添加到现有的 swift 项目 - 要测试的目标是灰色的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆