iOS Swift单元测试结果是未解析的标识符 [英] iOS Swift unit test result in unresolved identifier

查看:84
本文介绍了iOS Swift单元测试结果是未解析的标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

swift中用于测试的简单函数:

Simple function in swift for testing:

func testExample() {
    var tagname = "someClass()"
    var logger = Device("", "") //unresolved identifier

    XCTAssert(true, "Pass")
}

即使我使用import导入模块,我仍然无法使用模块中的类。虽然我可能在项目中弄乱了一些东西,但是我的示例项目中没有一个会让我使用模块类。

Even after I import my module with "import ", I still cannot use classes from my module. Also though I might have messed something up in the project, but NONE of my sample projects will let me use module classes.

看起来它应该可以工作但可能已经坏了beta 2。

Seems like it should work but might have broken in beta 2.

编辑:修复它
IDE没有检查参数名称。似乎Xcode仍然有点不确定

fixed it The IDE didn't pick up the check for the param names. Seems Xcode is still a tad iffy

推荐答案

我今天遇到了同样的问题,不确定这是否只是最近才可用 - 而不是在测试文件中使用导入TARGET_NAME 和/或将您的类/方法声明为 public ,您可以将文件添加到您的测试目标是通过XCode的文件检查器

I hit the same issue today, not sure if this is only available recently - rather than using import TARGET_NAME in your test file and/or declaring your classes/methods as public, you can add your file to your Tests target via XCode's File Inspector.

Cmd + 选择 + 1 在任何文件中显示,并选中目标下的框您的测试目标的会员资格

Cmd + Opt + 1 to show it while in any file, and check the box under Target Membership for your Tests Target.

您可能需要重建.... Cmd + b

You may need to rebuild.... Cmd + b.

这应该是我的系统特有的....我正在运行Xcode 6.3 beta 1,并测试通过Quick + Nimble,都安装了最新的cocoapods测试版。

Should this be specific to my system.... I'm running Xcode 6.3 beta 1, and testing via Quick + Nimble, both installed with the latest cocoapods beta.

这篇关于iOS Swift单元测试结果是未解析的标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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