簡體   English   中英

無法在單元測試中使用Cocoapod

[英]Unable to use Cocoapod in Unit Tests

我在我正在建造的應用程序中使用一個名為temple8的內部cocoapod。 這是我的Podfile:

platform :ios, '9.0'

def temple8
    pod 'j2objc-temple8-debug', :configuration => ['Debug'], :path => '../temple8/build/j2objcOutputs'
    pod 'j2objc-temple8-release', :configuration => ['Release'], :path => '../temple8/build/j2objcOutputs'
end

target 'cartful-ios' do
  use_frameworks!

  temple8

  pod 'Stripe'
  pod 'Alamofire', '~> 4.0'
  pod 'FontAwesomeKit', :git => 'https://github.com/PrideChung/FontAwesomeKit.git'
  pod 'KeychainAccess'
  pod 'pop', '~> 1.0'
  pod 'libPhoneNumber-iOS', '~> 0.8'
  pod 'AsyncDisplayKit', :git => 'https://github.com/facebook/AsyncDisplayKit.git'
  pod 'Intercom'
  pod 'Mixpanel-swift'
  pod 'UICountingLabel'
  pod 'DTFoundation'

  target 'cartful-iosTests' do
    inherit! :search_paths
    temple8
  end

  target 'cartful-iosUITests' do
    inherit! :search_paths
    temple8
  end

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'
        end
    end
end

我需要在我的測試中引用temple8的部分,這就是我將它包含在兩個測試目標中的原因。 但是當我運行任何測試時,我會得到一長串錯誤,如下所示:

objc [83693]:類PLBuildVersion在/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices(0x112334998)中實現和/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices(0x112156880)。 將使用兩者之一。 哪一個未定義。

我最初認為類的重復是由於在測試目標和應用程序的目標中都包含了temple8。 但是,如果我從測試目標中刪除temple8,任何時候我嘗試使用@testable import ...在我的測試中,我得到了一個

Failed to import bridging header...

構建錯誤。 這意味着測試無法找到app的橋接頭中的temple8頭文件。 所以我不確定這里最好的方法是什么。

據我所知,警告並不是你所做的。 我想我看到其他人有同樣的問題,據我所知,這是Apple最新SDK的一個問題。 我說你現在可以安全地忽略它。 以下是一些人有同樣的問題:

檢查此答案以獲取更多信息。

我不認為你需要在測試目標中使用temple8 - 它應該只是用於測試的庫:這是一個例子

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM