How to resolve “Unable to start status bar server. Failed to check into com.apple.UIKit.statusbarserver: unknown error code” exception

Posted on May 20, 2013

Ever wondered how to resolve the following error while executing GHUnitTest by Command Line?

*** Assertion failure in -[UIStatusBarServerThread main], /SourceCache/UIKit_Sim/UIKit-2372/UIStatusBarServer.m:96<br /> *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Unable to start status bar server. Failed to check into com.apple.UIKit.statusbarserver: unknown error code’

In my situation, the exception was caused by having an iPhone Simulator session opened while executing the CLI tests. So, in order to resolve the issue, I simply had to add

killall -s "iPhone Simulator" &> /dev/null<br /> if [ $? -eq 0 ]; then<br /> killall -m -KILL "iPhone Simulator"<br /> fi

on top of the run script file (RunTests.sh) which is executed as last “build phase” of the build process.

EDIT: I wrote another post explaining how to solve the error after migrating to XCode 5.