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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With