Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libraries not found when using CocoaPods with iOS logic tests

I am trying to write some iOS logic tests against classes in my project that use functionality from some of the libraries in my podspec. I am using the standard unit test bundle provided in Xcode (although not Application Tests, just Unit Tests).

For example, I use Magical Record, and I have that library linked in my podspec. It is present in the Pods project in my workspace, and works as expected when the app is running in the simulator or on the device. When I try to link to the test the object that uses Magical Record, however, I get a linker error stating that it can't find the selectors from Magical Record. I have tried updating my HEADER_SEARCH_PATH in my logic testing bundle, even hard coding it to the headers directory created by CocoaPods, but no luck.

I can run unit tests against classes that do not use CocoaPods libraries with no problem.

Am I going about this wrong? Should I be doing something else to get the compiler to see the CocoaPods libraries?

like image 627
Mark Struzinski Avatar asked Jan 24 '13 23:01

Mark Struzinski


1 Answers

CocoaPods 1.0 has changed the syntax for this. It now looks like this:

def shared_pods     pod 'SSKeychain', '~> 0.1.4'     ... end  target 'Sail' do     shared_pods end  target 'Sail-iOS' do     shared_pods end 

Pre CocoaPods 1.0 answer

What you want to use is link_with from your Podfile. Something like:

link_with 'MainTarget', 'MainTargetTests' 

Then run pod install again.

like image 88
Keith Smiley Avatar answered Oct 11 '22 13:10

Keith Smiley