I'm trying to add OCMock to my existing Cocoa project, but am running to a strange problem that I don't see anyone else cover.
I finally isolated it to the following: if I simply add OCMock.framework reference to my project (i.e. drag it in somehow into Link Binary With Libraries build phase), when I run tests, the real app gets launched instead.
Without OCMock, the output is normal:
Test Suite 'Multiple Selected Tests' started at 2013-02-07 20:07:03 +0000
With OCMock framework link (partial output):
Error loading MyProjTests.octest/Contents/MacOS/MyProjTests
Library not loaded: @rpath/OCMock.framework/Versions/A/OCMock
Reason: image not found
IDEBundleInjection.c: Error loading bundle '/Users/alex/Library/Developer/Xcode/DerivedData/MyProj-bqwyxyspdiudktfnjcdgibdmpgsa/Build/Products/Debug/MyProjTests.octest'
Other app output then appears as normal after this point. While the app is running, test progress is spinning on last tab of project navigator, and doesn't stop until you Quit the app. So test is supposedly in progress the whole time your app is running.
Clearing test host or bundle loader didn't solve, only produced linking errors for wrong architecture.
I'm using latest Xcode, 4.6. Any help greatly appreciated.
OK, finally figured it out, before I hit Submit here on SO, so I figured I'd share the answer. The problem was that OCMock.framework wasn't available at runtime.
The official OCMock steps just say download and add to target, but don't tell you to add a copy phase. I added a new phase in the test target to copy the framework into the Products Directory and the tests now run fine.
It was very unexpected that the main app would launch, and I hope this helps someone else.
edit:
Added pictures. Everyone loves pictures
Step 1
Step 2
Step 3
Step 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With