Adam Colvin
Adam Colvin

Reputation: 791

Unable to use Cocoapod in Unit Tests

I'm using an in-house cocoapod called temple8 in an app that I'm building. Here's my 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

I need to reference parts of temple8 in my tests which is why I've included it in both test targets. But then when I run any of my tests, I get a long list of errors like this:

objc[83693]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x112334998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x112156880). One of the two will be used. Which one is undefined.

I initially thought that the duplication of classes was caused by including temple8 in both the test targets and the app's target. But if I remove temple8 from the test targets, any time I try to use @testable import ... in my tests, I get a

Failed to import bridging header...

build error. Meaning that the temple8 header files in the app's bridging header cannot be found by the tests. So I'm unsure what the best approach is here.

Upvotes: 5

Views: 1444

Answers (2)

Mihai Fratu
Mihai Fratu

Reputation: 7663

As far as I know that warning is not something you did. I think I saw some other people having the same issue and as far as I can tell it's a problem in the latest SDK from Apple. I say you can safely ignore it for now. Here are some people having the same issues:

Check this answer to get more info.

Upvotes: 4

orta
orta

Reputation: 4285

I don't think you'll need the temple8 inside your test targets - it should just be the libraries for testing: Here's an example.

Upvotes: 1

Related Questions