无法在单元测试中使用Cocoapod

时间:2017-02-09 21:42:03

标签: objective-c swift xcode unit-testing cocoapods

我正在使用一个名为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头文件。所以我不确定这里最好的方法是什么。

2 个答案:

答案 0 :(得分:3)

据我所知,警告不是你所做的。我想我看到其他一些人有同样的问题,据我所知,这是Apple最新SDK的一个问题。我说你现在可以安全地忽略它。以下是一些人有同样的问题:

选中此answer以获取更多信息。

答案 1 :(得分:1)

我认为您不需要测试目标中的temple8 - 它应该只是用于测试的库:这里是example

相关问题