Search code examples
iosunit-testingxcode5cocoapodsocmockito

Questions about OCMockito setup with Cocoapods


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


Solution

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