ios 将 XCTest 导入到现有项目中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19230002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:10:40  来源:igfitidea点击:

Import XCTest in to existing project

iosxcodeunit-testing

提问by aug2uag

I added a new target as a Cocoa Touch Unit Testing Bundle, named the directory "MyAppTests", and the actual framework is not active-- it is highlighted red

我添加了一个新目标作为 Cocoa Touch Unit Testing Bundle,命名为“MyAppTests”目录,实际框架未激活——它以红色突出显示

enter image description here

在此处输入图片说明

When I add the framework by the 'link binary with libraries' in the 'build phases' tab technique, a new Framework is added, instead of updating the one that was created with adding the target.

当我通过“构建阶段”选项卡技术中的“链接二进制与库”添加框架时,会添加一个新框架,而不是更新通过添加目标创建的框架。

enter image description here

在此处输入图片说明

When I go to run the code, I then run in to all sorts of troubles, ranging from linking errors to other frameworks not being recognized.

当我去运行代码时,我会遇到各种各样的麻烦,从链接错误到其他框架无法识别。

How can I activate the XCTest.framework that was generated when I added target? Please help, thank you!

如何激活添加目标时生成的 XCTest.framework?请帮忙,谢谢!

回答by JuJoDi

XCTest.framework is the bundle that Xcode uses to enable

XCTest.framework 是 Xcode 用来启用的包

#import <XCTest/XCTest.h>

To add test cases to an existing project select the target, right click > file > new > objective c test case class. Then in your build phases you can add the XCTest.Framework. Make sure you check the add to target boxes when creating the test case.

要将测试用例添加到现有项目中,请选择目标,右键单击 > 文件 > 新建 > 目标 c 测试用例类。然后在您的构建阶段,您可以添加 XCTest.Framework。确保在创建测试用例时选中添加到目标框。