views:

175

answers:

2

I'm using GH-Unit for my unit tests. I've set it up according to the instructions, but I'm getting an "Undefined Symbol" error on this line:

#import "GHUnit.h"
#import "ChecklistAppDelegate.h"

@interface TestAppDelegate : GHTestCase {}
@end

@implementation TestAppDelegate

- (void)testStoringProperties {
    ChecklistAppDelegate *appDelegate = [[ChecklistAppDelegate alloc] init];
}

If I add ChecklistAppDelegate to the Tests target, the undefined symbol error goes away, but I get 37+ errors, one for each declaration of a Core Data class in my AppDelegate (there's a lot). Most of them are of the form, expected specifier-qualifier-list before 'NSPersistentStoreCoordinator'

I thought I might solve this by linking my Tests target against the Core Data framework, but that didn't work. I also tried #import <CoreData/CoreData.h> in my AppDelegate file, but that didn't work either.

Any ideas? I've tried removing all traces of GH-Unit and re-adding it a few times and it's still not working.


Here is the error from the build result

Undefined symbols:
  ".objc_class_name_ChecklistAppDelegate", referenced from:
      literal-pointer@__OBJC@__cls_refs@ChecklistAppDelegate in TestAppDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
A: 
Undefined symbols:
 ".objc_class_name_ChecklistAppDelegate", referenced from:
     literal-pointer@__OBJC@__cls_refs@ChecklistAppDelegate in TestAppDelegate.o

You need to add ChecklistAppDelegate.m to your Tests target.

If I add ChecklistAppDelegate to the Tests target, the undefined symbol error goes away, but I get 37+ errors, one for each declaration of a Core Data class in my AppDelegate (there's a lot). Most of them are of the form, expected specifier-qualifier-list before 'NSPersistentStoreCoordinator'

Declaring Core Data classes is the job of the Core Data headers. I think you mean something else, but I'm not sure what. Please edit your question to include the code, exactly where it is (which file), and the errors.

Peter Hosey
I meant declaration of variables with a core-data class. Posting the code and errors in a sec.
kubi
A: 

Fixed it. I added

#import <CoreData/CoreData.h>

to my Tests_Prefix.pch prefix header file.

kubi