如何修复单元测试文件中缺少的模块?

时间:2017-05-25 18:12:47

标签: ios iphone swift xcode unit-testing

所以我在Swift中进行单元测试非常新。在我的项目中,我使用了几个安装在我的可可豆荚中的框架,但是当我要在我的测试文件中编写一些代码时,我总是得到这个错误。 missing module: Firebase, Eureka, ImageRow

enter image description here

我试图在@testable上面导入这些模块,但不知何故它没有识别模块。它继续说module not found。我还尝试删除inherit search paths中的我的广告连播,它仍然在询问我是否需要导入这些模块。这是我的可可豆荚。

target 'ProjectRed' do

  use_frameworks!
  pod 'Firebase'
  pod 'Eureka'
  pod 'ImageRow'
  pod ‘Firebase/Database’
  pod ‘Firebase/Storage’

  # Pods for ProjectRed

  target 'ProjectRedTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'ProjectRedUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

2 个答案:

答案 0 :(得分:1)

  target 'ProjectRedTests' do
  inherit! :search_paths
  pod 'Firebase'
  pod 'Eureka'
  pod 'ImageRow'
  pod ‘Firebase/Database’
  pod ‘Firebase/Storage’

我将这些模块放在ProjectRedTests中。

答案 1 :(得分:0)

您还需要将这些框架添加到测试目标中。

  1. 在项目的“目标”部分中选择您的测试目标。
  2. 选择Build Phases选项卡。
  3. 将您的框架添加到Link Binary With Libraries部分。
  4. (注意:您可能需要在Link Binary With Libraries之前添加一个Copy Files阶段,以使它们进入正确的位置。)