Cocoapods测试链接器错误 [英] Cocoapods testing linker error

查看:67
本文介绍了Cocoapods测试链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我构建测试目标(Xcode生成的标准目标)时,构建都会失败并出现一个神秘错误:

Whenever I build my testing target (the standard target that Xcode generates), the build fails with an cryptic error:

framework not found Pods_AppName_AppNameTests

这是指无法找到测试生成的目标容器。
我的podfile非常简单:

which I take to mean the pod generated target for my tests can't be found. My podfile is pretty simple:

use_frameworks!

target 'AppName' do

  pod 'ReactiveCocoa'
  pod 'RealmSwift'
  pod 'ObjectMapper'
  pod 'Moya'
  pod 'Moya/ReactiveCocoa'
  pod 'pop'
  pod 'Heimdallr'
  pod 'Heimdallr/ReactiveCocoa'
  pod 'Alamofire'
  pod 'AlamofireImage'
  pod 'SwiftDate'
  pod 'DropdownAlert'
  pod 'NibDesignable'


  target 'AppNameTests' do
    pod 'Quick'
    pod 'Nimble'
  end
end

我使用Cocoapods 1.0.1。

I'm using Cocoapods 1.0.1.

编辑:

这不是我的podfile的格式。这是通过运行pod init给我的默认设置。 cocoapods中可能有一个bug,但是格式正确。

It is NOT the format of my podfile. This is the default setup given to me by running pod init. There may very well be a bug in cocoapods but the format is correct.

编辑2:

如果我包括:

inherit! search_paths

在我的测试目标中,测试失败:

in my test target, the tests fail saying:

The bundle "MyApp_Tests" couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.

如果没有这一行,测试也无法建立,但是这次出现链接器错误:

Without that line, the tests also fail to build but this time with a linker error:

Ld /Users/travis/Library/Developer/Xcode/DerivedData/Reactify-fqgxzcgedmqljrangqdkxpwdfxne/Build/Intermediates/Reactify.build/Debug-iphonesimulator/Reactify_Tests.build/Objects-normal/ i386 / Reactify_Tests正常的i386

Ld /Users/travis/Library/Developer/Xcode/DerivedData/Reactify-fqgxzcgedmqljrangqdkxpwdfxne/Build/Intermediates/Reactify.build/Debug-iphonesimulator/Reactify_Tests.build/Objects-normal/i386/Reactify_Tests normal i386

该特定错误来自Travis,但我在本地Xcode中得到了相同的错误。

That particular error is from Travis but I get the same one in Xcode locally.

推荐答案

上周我也一直在与之作斗争-最终我发现可靠的解决方案是添加继承! search_paths ,从测试目标中安装pod,然后将其删除,然后再次进行pod安装,如下所示:

I've been battling with this the last week as well -- the "solution" I eventually found to work reliably was to add inherit! search_paths, pod install, then remove it, and pod install again, from the test target, like this:

source 'https://github.com/CocoaPods/Specs.git'

project 'CityWeather/CityWeather.xcodeproj'
install! 'cocoapods',
         :deterministic_uuids => false

use_frameworks!

platform :ios, '9.3'

abstract_target 'CityWeather_Base' do

  <... pod list here, contents don't seem to matter ...>

  target 'CityWeather' do
  end

  target 'CityWeatherTests' do
  # NB. If it starts refusing to link the test frameworks,
  # adding and then removing inherit! :search_paths here appears to help.
  #inherit! :search_paths
  end

end

至少没有那么麻烦而不是每次都在您身上创建一个新目标,根据我上周的预测,我预计很快就会在您身上发生。很烦人。我花了尽可能多的时间尝试从发生问题的提交日志中推断出问题,但这并不是很明显。如果可以设法找到足够的时间来解决一个有用的问题,我将在这里进行更新。但是与此同时,希望我的解决方案可以一定程度上提高您的生产率。

That's less hassle at least than creating a new target every time it happens to you, which judging by my last week I predict to happen to you shortly. Very annoying. Spent as much time as I could spare to try to deduce from the commit logs where the problem occurs, but it's not straightforwardly obvious. I'll update here if I manage to find the time to figure out the problem enough to open a useful issue. But in the meantime, hopefully my "solution" will improve your productivity somewhat.

这篇关于Cocoapods测试链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆