开发者

Unit tests only run automatically when active SDK is "simulator"?

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开发者_如何学Go 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜