Swift 单元测试无法识别新的 class 初始值设定项

Swift unit test not recognizing new class initializer

我更改了 Swift class 上的初始值设定项签名。我的其他 swift classes 识别出这个变化,但是我的单元测试 class 在我更新方法调用

时给我一个错误
Extra argument 'bundle' in call

这是我的新初始化程序签名:

var vc = ListController(nibName: nil, bundle: nil, contractor: theContractor)

旧的是:

var vc = ListController(nibName: nil, bundle: nil, contractor: theContractor, estimate: theEstimate)

我尝试过的事情:

  1. 清理项目
  2. 从单元测试目标和测试目标的编译源中删除并重新添加了 ListController 和测试 class
  3. 删除了项目的派生数据
  4. 完全重写了测试 class 从头开始​​只是为了把它放在一个新的文件名下

目前的底线是我的测试 class 无法识别初始化程序签名更改。

ListController写在Swift以及测试class.

即使自动完成也会输入正确的方法签名。但是如果你在方法签名上执行 CMD+Space 它说 "Symbol Not Found".

来自 Sergiy Salyuk here:

Swift makes inherited initializers inaccessible for clients of your derived class when you add a designated initializer. It looks similar to private inheritance in C++ where the inherited methods/data are implicitly moved to the "private" class section. The reason is simple: if there is a custom initializer then your class probably requires this initializer to construct class "invariant". But there is a bug: if you create class derived from UITableViewController and add custom initializer that calls super.init(style:) it will fail with use of unimplemented initializer 'init(nibName:bundle:)'

听起来您遇到了本质上相同的问题?