繁体   English   中英

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

[英]How to fix missing module in unit-test file?

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

在此输入图像描述

我试图在@testable上面导入这些模块,但不知怎的,它无法识别模块。 它继续说module not found 我还尝试在inherit search paths删除我的pod,它仍然要求我需要导入这些模块。 这是我的可可豆荚。

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
  target 'ProjectRedTests' do
  inherit! :search_paths
  pod 'Firebase'
  pod 'Eureka'
  pod 'ImageRow'
  pod ‘Firebase/Database’
  pod ‘Firebase/Storage’

对我来说,将这些模块放在ProjectRedTests中。

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

  1. 在项目的“目标”部分中选择您的测试目标。
  2. 选择Build Phases选项卡。
  3. 将框架添加到Link Binary With Libraries部分。

(注意:您可能需要在Link Binary With Libraries之前添加Copy Files阶段,以使它们进入正确的位置。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM