My unit test target crashes on Xcode 7.
I perform unit tests on my project with a designated app delegate class, different from my regular app delegate . The UnitTestAppDelegate
is not a member of the app target, only of the test target.
In Xcode 6 it is working, the correct delegate is used, But in Xcode 7 (beta 6) the app crashes when trying to load to test delegate. I test using simulators, both iOS 8 and 9.
The file is not known to the app target:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to instantiate the UIApplication delegate instance. No class named UnitTestAppDelegate is loaded.'
My main.m
file looks like this:
int main(int argc, char* argv[])
{
int returnValue;
@autoreleasepool
{
if (NSClassFromString(@"XCTest") != nil)
{
//use the test delegate
returnValue = UIApplicationMain(argc, argv, nil, @"UnitTestAppDelegate");
}
else
{
//use the normal delegate
returnValue = UIApplicationMain(argc, argv, nil, @"AppDelegate");
}
}
return returnValue;
}
I'm also attaching a screen shot of how my scheme is configured (the run and test are in the same scheme, although I also tried separating them).
Adding my UnitTestAppDelegate
as a member of the app target fixes the crash, but I obviously don't want to add the file to my app.
Anyone else encountered this?
Any ideas?
Aucun commentaire:
Enregistrer un commentaire