Cocoapods测试链接器错误

bar*_*dog 11 ios cocoapods

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

framework not found Pods_AppName_AppNameTests
Run Code Online (Sandbox Code Playgroud)

我认为这意味着我的测试的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
Run Code Online (Sandbox Code Playgroud)

我正在使用Cocoapods 1.0.1.

编辑:

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

编辑2:

如果我包括:

inherit! search_paths
Run Code Online (Sandbox Code Playgroud)

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

The bundle “MyApp_Tests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
Run Code Online (Sandbox Code Playgroud)

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

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

Ale*_*ylo 7

我上周也一直在努力解决这个问题 - 我最终发现可靠工作的"解决方案"是添加inherit! search_paths,pod安装,然后从测试目标中删除它,再次安装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
Run Code Online (Sandbox Code Playgroud)

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