Xcode - 测试类文件是模块的一部分,忽略导入 [英] Xcode - Test class File is part of module, ignoring import

查看:101
本文介绍了Xcode - 测试类文件是模块的一部分,忽略导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个带有测试的iOS项目,一切正常。

So I have an iOS project with tests and everything was working properly.

我觉得需要更改项目名称。我按照苹果公司的文档指示,
选择了该项目并更改了名称。

I felt the need to change the project name. I did as indicated at apple's docs, selected the project and changed its name.

经过一段时间的更新后,最终工作,应用程序运行好吧,但我仍然遇到问题。

After a while of updating things for this to finally work, the app runs ok, but I'm still having a problem.

由于这个恼人的问题,我无法运行测试。我确定这是一个基本的东西,但我仍然无法弄明白。

I can't run the tests because of this annoying issue. I'm sure it's a basic thing, but still I can't quite figure it out.

这是我的测试类(为了我正在使用的问题) a Foo 示例)

Here's my test class (for the sake of the question I'm using a Foo example)

@testable import MyApp // File FooTests is part of module MyApp. Ignoring import.

class FooTests: QuickSpec {

  override func spec() {

     describe("a foo test") {
         it("tests foo") {
             let return = Foo.barMethod()
             XCTAssertEqual(return, "expected", "Expected something, got \(return) instead")
         }
    }
 }

Foo 类没有被识别,我得到的错误是测试类是 MyApp 的一部分,但实际情况并非如此。

The Foo class is not being recognized, and I get the error that the test class is part of MyApp which is not the case.

我应该在哪里寻找?

推荐答案

我偶然发现同样的问题,你的帖子很有帮助。我发现的是将产品名称更改为 AppNameTests ,根据您的示例,产品模块名称为正确反映,您不必在 $(PRODUCT_NAME:c99extidentifier)的末尾添加测试 c99extidentifier 似乎是指产品名称

I just stumbled on the same problem, and your post was helpful. What I found out is by change the Product Name to AppNameTests, as per your example, then the product module name is reflected correctly and you don't have to add Tests at the end of $(PRODUCT_NAME:c99extidentifier). c99extidentifier seems torefers to Product Name.

摘要:


  • 在项目中选择您的测试目标

  • 导航至构建设置 - >打包

  • 产品名称更改为之前的测试目标,可能附加测试

  • 我相信按 Apple重命名项目不包括更新 @testable 中的模块,所以我不得不这样做这个手动

  • select your test target in Project
  • navigate to Build Settings -> Packaging
  • change the Product Name to your previous test target, likely appending Tests
  • I believe the rename as per Apple's renaming a project doesn't include the updating the module in @testable, so I had to do this manually

这篇关于Xcode - 测试类文件是模块的一部分,忽略导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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