Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use Kiwi to test with frameworks added by CocoaPods

I'm having an issue getting the testing framework Kiwi to work with frameworks added through CocoaPods. I have both AFNetworking and Lumberjack being loaded in, and both are causing a failure in the test. The test only fails if any source files in my project being built into the test target are including files from CocoaPods. This is the message I'm receiving:

2012-10-15 13:10:44.386 otest[47294:7e03] The test bundle at /Users/[username]/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/KiwiUnitTest.octest could not be loaded because a link error occurred. It is likely that dyld cannot locate a framework framework or library that the the test bundle was linked against, possibly because the framework or library had an incorrect install path at link time.

I've followed all the instructions on both CocoaPods and Kiwi.

For example, I have a APIClient class. It includes AFHTTPClient.h. If I run a test without the APIClient.m being built into the test target the test builds and runs fine. If I do include the source into it it says everything succeeded, but not tests are ran, and the above error message is in my log.

Thanks, James

like image 322
James Richard Avatar asked Oct 15 '12 20:10

James Richard


2 Answers

I had a similar problem. Managed to fix it by setting Test Host parameter in KiwiUnitTest's Build Settings (in "Unit Testing" section) to $(BUNDLE_LOADER).

enter image description here

like image 169
Pooria Azimi Avatar answered Oct 06 '22 00:10

Pooria Azimi


The missing pch.dia issue can be caused by a few different factors but in my case and the case of some colleagues, this resolved the missing pch.dia

Uninstall CocoaPods and install 0.17.1

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 0.17.1 --verbose

Lock your Kiwi version to 2.05:

target :KiwiUnitTest, :exclusive => true do
  pod 'Kiwi', '2.0.5'

Clean your Xcode project including Derived Data. Close down Xcode, re-open the project and build.

like image 30
james_womack Avatar answered Oct 06 '22 00:10

james_womack