12

Whenever I build my testing target (the standard target that Xcode generates), the build fails with an cryptic error:

framework not found Pods_AppName_AppNameTests

which I take to mean the pod generated target for my tests can't be found. My podfile is pretty simple:

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

I'm using Cocoapods 1.0.1.

EDIT:

It is NOT the format of my podfile. This is the default setup given to me by running pod init. There may very well be a bug in cocoapods but the format is correct.

EDIT 2:

If I include:

inherit! search_paths

in my test target, the tests fail saying:

The bundle “MyApp_Tests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.

Without that line, the tests also fail to build but this time with a linker error:

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

That particular error is from Travis but I get the same one in Xcode locally.

barndog
  • 6,975
  • 8
  • 53
  • 105
  • I tried this (with your pod file) and all works fine! please provide a reproducible example – Daij-Djan Jun 04 '16 at 13:45
  • Have you tried deleting all the installed frameworks from your derived data directory? – davetw12 Jun 04 '16 at 15:26
  • 1 million + one times. I've tried everything; cleans, wipes, restarts, installs, you name it. If you see my answer, I give a bit of an explanation as how to I finally got it working, although there's by no means a definitive answer. – barndog Jun 04 '16 at 15:27

2 Answers2

8

I've been battling with this the last week as well -- the "solution" I eventually found to work reliably was to add inherit! search_paths, pod install, then remove it, and pod install again, from the test target, like this:

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

That's less hassle at least than creating a new target every time it happens to you, which judging by my last week I predict to happen to you shortly. Very annoying. Spent as much time as I could spare to try to deduce from the commit logs where the problem occurs, but it's not straightforwardly obvious. I'll update here if I manage to find the time to figure out the problem enough to open a useful issue. But in the meantime, hopefully my "solution" will improve your productivity somewhat.

Alex Curylo
  • 4,744
  • 1
  • 27
  • 37
3

It's the strangest thing and I absolutely tried this before, but I just deleted the test target, created a new one, and lo and behold, it works. The sole difference, as far I can tell, between the two targets is one was called MyApp_Tests and the other MyApp_ExampleTests. I'd be surprised if that was the cause but at this point it's hard to tell.

I will say though as a side note, the project I was referring to is not the only project I've seen this happen with. The last four of my projects have encountered this error, all created since Cocoapods 1.0.0. That leads me to believe that there's some hidden bug in the Cocoapods test setup which I'll have to investigate more.

Additionally, deleting the test target and making a new one only seemed to work in this particular case. In other projects, the error persists. And I can tell it's more than just my local setup because my travis builds would also fail consistently.

barndog
  • 6,975
  • 8
  • 53
  • 105
  • I second that it has something to do with CocoaPods 1.0.0. I recently upgraded and ran into a similar error a couple days ago. I ended up deleting all the pods from my derived data directory and reinstalling to fix it. – davetw12 Jun 04 '16 at 15:30
  • I actually did that is well but that seems to be only a temporary fix. I got my tests to run locally but as soon as travis ran the tests, it failed with much the same error. – barndog Jun 04 '16 at 15:43