【问题标题】:No such module 'RealmSwift'没有这样的模块'RealmSwift'
【发布时间】:2017-10-18 17:58:40
【问题描述】:

当我在测试中编译时,我总是得到这个结果“没有这样的模块'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

【问题讨论】:

  • 在 Xcode 中构建时,您还看到了哪些其他错误(如果有)?无法找到模块通常表示模块(或它所依赖的东西)构建失败。
  • 我添加了截图。

标签: unit-testing realm cocoapods integration-testing


【解决方案1】:

我必须添加到测试目标:

  target' AppTests' do
    inherit! : search_paths
  end

“@testable import App”必须包含在每个Test文件中(对应于主Target的名称)

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

【讨论】:

    【解决方案2】:

    我有同样的问题。对我有用的是:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      • 2017-02-09
      • 2019-02-21
      相关资源
      最近更新 更多