我正在使用 GH-Unit 进行单元测试。我已经按照说明进行了设置,但我在这一行收到“ undefined symbol ”错误:
#import "GHUnit.h"
#import "ChecklistAppDelegate.h"
@interface TestAppDelegate : GHTestCase {}
@end
@implementation TestAppDelegate
- (void)testStoringProperties {
ChecklistAppDelegate *appDelegate = [[ChecklistAppDelegate alloc] init];
}
如果我添加 ChecklistAppDelegate
到Tests
目标, undefined symbol 错误消失了,但我收到了 37 个以上的错误,其中一个对应于我的 AppDelegate 中 Core Data 类的每个声明(有很多)。其中大多数的形式为 expected specifier-qualifier-list before 'NSPersistentStoreCoordinator'
我想我可以通过链接我的 Tests
来解决这个问题针对核心数据框架的目标,但这不起作用。我也尝试过#import <CoreData/CoreData.h>
在我的 AppDelegate 文件中,但这也不起作用。
有什么想法吗?我尝试删除 GH-Unit 的所有痕迹并重新添加几次,但仍然无法正常工作。
<小时/>这是构建结果的错误
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
最佳答案
Undefined symbols: ".objc_class_name_ChecklistAppDelegate", referenced from: literal-pointer@__OBJC@__cls_refs@ChecklistAppDelegate in TestAppDelegate.o
您需要将 ChecklistAppDelegate.m 添加到您的测试目标。
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'
声明 Core Data 类是 Core Data header 的工作。我认为你的意思是别的,但我不确定是什么。请编辑您的问题以包含代码、其确切位置(哪个文件)以及错误。
关于iphone - GH 单位和 "Undefined symbols"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2210834/