簡體   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