IOS Unit Testing in Xcode
I have an existing app that I am migrating to iOS. I am currently running unit tests with every build. My tests are integrated into my application for ease of testing, so when I passed -t
, my tests ran. The very first thing I do in mine main
is this:
for(int ii=1;ii<argc;++ii)
{
if(strcmp("-t", argv[ii]) == 0)
return RunAllTests(argc, argv);
}
This works great on the desktop, and I would like it to work with iOS. When I manually run the app in the simulator with the checkbox passed in -t
, the tests run as expected. Unfortunately this does not work when launched as a post-build step. I run this script on each assembly: $TARGET_BUILD_DIR/$TARGET_NAME.app/$TARGET_NAME -t
. When it starts, I get the following error:
dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit
Referenced from: /development/test/projects/../bin/test.app/test
Reason: image not found
/development/test/projects/../obj/test.build/Script-27DEB636151ECEC80003FE53.sh: line 2: 8720 Trace/BPT trap: 5 $TARGET_BUILD_DIR/$TARGET_NAME.app/$TARGET_NAME -t
Command /bin/sh failed with exit code 133
I assume this is because the IDE is trying to run the executable directly, not in the simulator.
I know iOS has a unit test framework, but I already have a workflow and wouldn't want to rewrite all my tests to unit test only on iOS. Is there a way to get Xcode to run my post build step in the simulator so that my tests run correctly?
source to share