After upgrading from Xcode 6.4 to Xcode 7 (and now 7.0.1) my project crashes when starting unit tests. My iOS project is using Magical Record and the app crashes at this assertion:
+ (NSManagedObjectContext *) MR_defaultContext
{
@synchronized(self) {
NSAssert(MagicalRecordDefaultContext != nil, @"Default context is nil! Did you forget to initialize the Core Data Stack?");
return MagicalRecordDefaultContext;
}
}
I've commented out all of my previous tests, and both of these tests show the same behavior:
#import <XCTest/XCTest.h>
@interface BadTests : XCTestCase
@end
@implementation BadTests
- (void)setUp {
[super setUp];
}
- (void)tearDown {
[super tearDown];
}
- (void)testSanity {
XCTAssert(1 == 1);
}
@end
and
#import <XCTest/XCTest.h>
#import <MagicalRecord/MagicalRecord.h>
@interface BadTests : XCTestCase
@end
@implementation BadTests
- (void)setUp {
[super setUp];
NSLog(@"*** USING IN MEMORY STORE ***");
[MagicalRecord setLoggingLevel:MagicalRecordLoggingLevelDebug];
[MagicalRecord setupCoreDataStackWithInMemoryStore];
}
- (void)tearDown {
[MagicalRecord cleanUp];
[super tearDown];
}
- (void)testSanity {
XCTAssert(1 == 1);
}
@end
Reverting back to Xcode 6 with the same tests resolves the issue.