So I have been playing with GHUnit today, and have some nice tests which run just fine in the similator in XCode4. When I run them on the iPhone itself I get the following error:
'Unable to instantiate the UIApplication delegate instance.
No class named GHUnitIPhoneAppDelegate is loaded.'
Before you ask, yes I have the linker options -ObjC
and -all_load
set, and as I said, it works fine in the simulator, so why not the iPhone itself?
Puzzled!
I am not sure to have the real reason of this problem but I did find a workaround.
For a reason I am still not quite sure to understand replacing:
int retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIPhoneAppDelegate");
by
int retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIOSAppDelegate");
in the main file will fix the problem.
The class GHUnitIPhoneAppDelegate
inherits from GHUnitIOSAppDelegate
but it is not included in the final binary (I ran a nm -a GHUnitIPhoneAppDelegate|grep IPhoneApp
with no result).
A wild guess is that since the class only inherits from it (no additional methods or attributes) and because nowhere in the framework this class is instantiated (only mentioned through a string), the compiler, to save space, removes it from the binary information in iOS mode.
Hope this helps, at least that worked for me.