没有这样的模块'RealmSwift'

时间:2017-10-18 17:58:41

标签: unit-testing realm cocoapods integration-testing

enter image description here当我在Test中编译时,我总是得到这个结果“没有这样的模块'RealmSwift'”。

我在podfile中有以下内容。

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
# ignore all warnings from all pods
inhibit_all_warnings!

target 'App' do
   use_frameworks!
    pod 'RealmSwift'
    pod 'Fabric', '~> 1.6.3'
    pod 'Answers', '~> 1.3.5'
    pod 'DropDown', '~> 2'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0' # or '3.0'
    end
  end
end

我已经尝试过了,我仍然得到了同样的结果。

pod --version
pod cache clean Realm
pod cache clean RealmSwift
pod deintegrate || rm -rf Pods
pod install --verbose
rm -rf ~/Library/Developer/Xcode/DerivedData

我还删除了项目的“Pods”文件夹,文件“Podfile.lock”和“App.xcworkspace”,然后我运行pod install。

我正在使用Xcode 8.3.3和Swift 3

2 个答案:

答案 0 :(得分:1)

我必须添加到测试目标:

  target' AppTests' do
    inherit! : search_paths
  end

" @testable导入App"必须包含在每个测试文件中(对应于主要目标的名称)

测试文件不得包含任何非测试文件的文件(在目标成员中)。

答案 1 :(得分:0)

我有同样的问题。对我有用的事情如下:

如果您使用的是Xcode 9.只需使用推荐的设置进行更新即可。然后Xcode将识别Realm。