Question

I'm having troubles setting up OCMockito (and OCHamcrest) with Cocoapods on Xcode 5. This is my Podfile:

platform :ios, '5.0' 
pod 'RestKit', '~> 0.20.0'
pod 'OCMockito', '~> 1.0.0'
link_with ['WeatherApp', 'WeatherAppTests']

When I try to follow iOS Project Setup (https://github.com/jonreid/OCMockito#adding-ocmockito-to-your-project), Xcode can't find this imports:

#define HC_SHORTHAND
#import <OCHamcrestIOS/OCHamcrestIOS.h>

#define MOCKITO_SHORTHAND
#import <OCMockitoIOS/OCMockitoIOS.h>

So I tried to do this insted:

#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>

#define MOCKITO_SHORTHAND
#import <OCMockito/OCMockito.h>

It's working, but I don't know if that's fine.

Also, I have another question. As far as I understand, I'm linking RestKit and OCMockito to both my main target and my test target. Is it possible to link RestKit on both targets but link OCMockito only to the test target?

Thanks in advance for the help.

UPDATE:

This is the Pods.xcconfig generetad by Cocoapods:

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/OCHamcrest" "${PODS_ROOT}/Headers/OCMockito" "${PODS_ROOT}/Headers/RestKit" "${PODS_ROOT}/Headers/RestKit/RestKit" "${PODS_ROOT}/Headers/RestKit/RestKit/CoreData" "${PODS_ROOT}/Headers/RestKit/RestKit/Network" "${PODS_ROOT}/Headers/RestKit/RestKit/ObjectMapping" "${PODS_ROOT}/Headers/RestKit/RestKit/Support" "${PODS_ROOT}/Headers/SOCKit" "${PODS_ROOT}/Headers/TransitionKit"
OTHER_LDFLAGS = -ObjC -framework CFNetwork -framework CoreData -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration
PODS_ROOT = ${SRCROOT}/Pods

It seems that the IOS headers aren't setup correctly, is the pod wrong then?

UPDATE:

This are the contents of Pods/Headers/OCMockito

Pods/Headers/OCMockito

Was it helpful?

Solution

OCHamcrestIOS applies only to using the prebuilt iOS framework. When using CocoaPods, just import OCHamcrest.

OTHER TIPS

To use OCHamcrest (or OCMockito) in your test target bundle and not your main app you can add something like this to the Podfile:

target :YourTestTarget, :exclusive => true do
    pod 'OCHamcrest',   '~> 3.0'
    pod 'OCMockito',   '~> 1.0'
    #pod 'RestKit/Testing'
end

If you plan to unit test your RestKit mapping (etc) then you may want to include RestKit/Testing in your bundle also.

Then you'd just include it like this:

#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>

#define MOCKITO_SHORTHAND
#import <OCMockito/OCMockito.h>

This is what your complete Podfile might look like:

platform :ios, '5.1'
pod 'Appirater',    '~> 0.0.2'
pod 'FlurrySDK',    '~> 4.0.5'
pod 'RestKit',      '~> 0.21.0'
target :FooBarTests, :exclusive => true do
    #pod 'RestKit/Testing'
    pod 'OCHamcrest',   '~> 3.0'
    pod 'OCMockito',   '~> 1.0'
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top