iphone - GH 单位和 "Undefined symbols"错误

标签 iphone cocoa gh-unit

我正在使用 GH-Unit 进行单元测试。我已经按照说明进行了设置,但我在这一行收到“ undefined symbol ”错误:

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

@interface TestAppDelegate : GHTestCase {}
@end

@implementation TestAppDelegate

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

如果我添加 ChecklistAppDelegateTests目标, 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/

相关文章:

ios - 是否可以在iphone中存储一个ipa文件

iphone - 无法通过 YAJLiOS 解析 json 数据

iphone - 使用我的邮件帐户以编程方式撰写电子邮件,无需在 iPhone 的邮件客户端中进行配置

xcode - 如何从/Library/Application Support/文件夹中读取内容?

ios4 - 应用程序类的 GHUnit 链接器错误

iphone - 我应该如何在 iPhone 项目中指定 sqlite 数据库的路径?

objective-c - 将 subview 放置在另一个 View 上

objective-c - 获取当前键盘光标位置

iOS 单元测试 : simulate Home Button press etc

ios - Xcode 4 中 GHUnit + Hudson/Jenkins 的问题