It’s been a lot of time and efforts for me to set up the Jenkins CI server that would fetch new commits from git, run unit tests, build our iOS project, and publish the ipa file to a certain server.
The latest part I’d been fiddling around with recently is running unit tests automatically on each Jenkins build. They are written with GHUnit, but its CLI scripts are not compatible with the latest Xcode 4.5 and iOS SDK 6.0 out-of-box. The base manual I used is here: http://gabriel.github.com/gh-unit/docs/appledoc_include/guide_command_line.html.
First of all, the Makefile had to be altered to build a scheme in the workspace instead of a target in the project. Following this article, my improved Makefile looks this way:
Running: "/Users/user/Library/Developer/Xcode/DerivedData/test-abc/Build/Products/Debug-iphonesimulator/test.app/test" -RegisterForSystemEvents
test[7775:707] Warning: CFFIXED_USER_HOME is not set! It should be set to the simulated home directory.
test[7775:707] Unknown Device Type. Using UIUserInterfaceIdiomPad based on screen size
Terminating since there is no workspace.
** BUILD SUCCEEDED **
The CFFIXED_USER_HOME warning is fixed by uncommenting lines 11-16 in the RunTests.sh script:
123456
export CFFIXED_USER_HOME="$TEMP_FILES_DIR/iPhone Simulator User Dir" # Be compatible with google-toolbox-for-mac
if [ -d $"CFFIXED_USER_HOME" ]; then
rm -rf "$CFFIXED_USER_HOME"
fi
mkdir -p "$CFFIXED_USER_HOME"
PhaseScriptExecution "Run Tests (for Command-Line Support)" /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/test-hdladdygpxwhisfxxbxmrdenrtek/Build/Intermediates/test.build/Debug-iphonesimulator/test.build/Script-BA4CBAF81609EAC7005B495C.sh
cd /Users/Shared/Jenkins/Home/jobs/test/workspace/native/ios/src
/bin/sh -c /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/test-hdladdygpxwhisfxxbxmrdenrtek/Build/Intermediates/test.build/Debug-iphonesimulator/test.build/Script-BA4CBAF81609EAC7005B495C.sh
launch_msg(): Socket is not connected
Running: "/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/test-hdladdygpxwhisfxxbxmrdenrtek/Build/Products/Debug-iphonesimulator/test.app/test" -RegisterForSystemEvents
Test Suite 'Tests' started.
// …skipped…
Test Suite 'Tests' finished.
Executed 37 of 37 tests, with 0 failures in 0.348 seconds (0 disabled).
Failed tests:
Writing JUnit XML to:tmp/test-results.
Wrote JUnit XML successfully.
launch_msg(): Socket is not connected
Command /bin/sh failed with exit code 1
** BUILD FAILED **
After some debugging, I figured out the launch_msg(): Socket is not connected message is produced by launchctl command. My solution for now is to ignore the warnings, but launchctl returns non-zero exit code, and that’s why the build is considered failed. Replace the last line of RunTests.sh script with this: