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

2

10

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

Cist answered 15/10, 2012 at 20:23 Comment(0)
P
12

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

Prologize answered 25/10, 2012 at 11:44 Comment(1)
I wish I would of seen this 4 hours ago, fixed a very similar issue for me, thanksRoundy
M
2

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.

Misguide answered 8/4, 2013 at 23:0 Comment(1)
This worked for me. I'd add the pod setup and pod install steps in here, too.Fabrienne

© 2022 - 2024 — McMap. All rights reserved.