views:

72

answers:

1

I have followed the instructions Apple publishes for unit testing applications on iPhone and things work great when I set the active SDK to "iPhone Simulator". I have it configured to always build and run my tests as part of building the application itself.

Apple implies (by omission) that this should work all of the time, but the tests are skipped when I set the active SDK to "iPhone Device". I am also linking with OCMock, and instead of a failing test, this warning is in the build log:

ld: warning: in .../build/Debug-iphoneos/OCMock.framework/OCMock, missing required architecture arm in file

It's very nice to make the unit test bundle a dependency of the main application, so these tests run at every build, but its utility is greatly diminished if it doesn't work during device builds. Is this a known, but undocumented, limitation?

A: 

As Kristopher commented, this is just the way XCode behaves. The Run Script step at the end of your Unit Test target will actually run the built target when the SDK is set to Simulator, but if you look at the build output it will just balk when building against the Device SDK.

Basically, build your LogicTests against the Simulator SDK and build your ApplicationTests against the Device SDK. It's a pain, but that's just the way it works.

Also, if you want to get OCMock working for ARM (which you will likely want for Application Tests that run on the actual device), I believe their OCMock lib target is "fat"/Universal by default. That is, it will include both i386 code and arm code within the same library. You'll have the best results if you check out their repository and build it yourself.

Matt Baker
Surprising that no one else bothered to answer in all this time, but their loss is your +15 rep gain. :-)
Steve Madsen
Nice! I'm sure you figured this out well before then but just in case someone else has the same question I figured I'd write my thoughts. There's not much more discouraging than finding an exact account of your problems with no answer!
Matt Baker