繁体   English   中英

Cocoapods测试链接器错误

[英]Cocoapods testing linker error

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

framework not found Pods_AppName_AppNameTests

我认为这意味着我的测试的pod生成目标无法找到。 我的podfile非常简单:

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。

编辑:

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

编辑2:

如果我包括:

inherit! search_paths

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

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

如果没有该行,测试也无法构建,但这次出现了链接器错误:

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中获得了同样的错误。

我上周也一直在与此斗争 - 我最终发现可靠工作的“解决方案”是添加inherit! search_paths inherit! search_paths ,pod install,然后从测试目标中再次删除它和pod安装,如下所示:

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

这至少比每次碰巧你创造一个新目标更麻烦,从我上周的预测来看,我预计很快会发生在你身上。 很烦人。 花费尽可能多的时间来尝试从发生问题的提交日志中推断,但这并不是直截了当的。 如果我能找到时间找出足够的问题来打开一个有用的问题,我会在这里更新。 但与此同时,希望我的“解决方案”能够在一定程度上提高您的生产力。

这是最奇怪的事情,我之前绝对尝试过这个,但我刚刚删除了测试目标,创建了一个新目标,并且它看起来很有效。 据我所知,两个目标之间的唯一区别是一个名为MyApp_Tests ,另一个MyApp_ExampleTests 如果这是原因我会感到惊讶,但在这一点上很难说。

我会说作为旁注,我所指的项目并不是我见过的唯一一个项目。 我的最后四个项目遇到了这个错误,都是自Cocoapods 1.0.0以来创建的。 这让我相信Cocoapods测试设置中存在一些隐藏的错误,我将不得不进行更多调查。

此外,删除测试目标并创建一个新目标似乎只适用于这种特殊情况。 在其他项目中,错误仍然存​​在。 我可以告诉它不仅仅是我的本地设置,因为我的travis构建也会一直失败。

暂无
暂无

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

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