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

Ios4 应用程序类的GHUnit链接器错误,ios4,xcode4,linker-errors,gh-unit,Ios4,Xcode4,Linker Errors,Gh Unit,我正在尝试运行GHUnit测试,以测试setter是否可以在我的应用程序中为NSManagedObject对象工作。我的应用程序名为Machine,我的GHUnit目标名为Tests。我已经将机器作为依赖项添加到测试目标中。我的测试对象称为目标。下面是代码,链接中的错误如下所示 #import <GHUnitIOS/GHUnit.h> #import <CoreData/CoreData.h> #import "Goal.h" #import "GoalRec.h" @

我正在尝试运行GHUnit测试,以测试setter是否可以在我的应用程序中为NSManagedObject对象工作。我的应用程序名为Machine,我的GHUnit目标名为Tests。我已经将机器作为依赖项添加到测试目标中。我的测试对象称为目标。下面是代码,链接中的错误如下所示

#import <GHUnitIOS/GHUnit.h>
#import <CoreData/CoreData.h>
#import "Goal.h"
#import "GoalRec.h"

@interface ControllerTests : GHTestCase { }
@property (retain) Goal *goal;
@end

@implementation ControllerTests
@synthesize goal;

- (BOOL)shouldRunOnMainThread {
// By default NO, but if you have a UI test or test dependent on running on the main    thread return YES
return NO;
}

- (void)setUpClass {
    // Run at start of all tests in the class
}

- (void)tearDownClass {
    // Run at end of all tests in the class
}

- (void)setUp {
    // Run before each test method
    self.goal = [[[Goal alloc] init] autorelease];
}

- (void)tearDown {
    // Run after each test method
    self.goal = nil;   // prevents memory leak
}  

- (void)testImageArray {

    NSString *str = @"Hello";
    Goal *obj = self.goal;
    obj.goal = str;
    GHAssertEqualStrings(obj.goal, @"Hello", nil);

}
#导入
#进口
#导入“Goal.h”
#输入“GoalRec.h”
@接口控制器测试:GHTestCase{}
@财产(保留)目标*目标;
@结束
@实现控制器测试
@综合目标;
-(BOOL)应该运行非主线程{
//默认情况下为否,但如果有UI测试或依赖于在主线程上运行的测试,则返回YES
返回否;
}
-(无效)设置类{
//在类中所有测试开始时运行
}
-(无效)拆卸类{
//在类中所有测试结束时运行
}
-(无效)设置{
//在每个测试方法之前运行
self.goal=[[goal alloc]init]autorelease];
}
-(无效)拆卸{
//按照每个测试方法运行
self.goal=nil;//防止内存泄漏
}  
-(void)testImageArray{
NSString*str=@“你好”;
目标*obj=自我目标;
obj.goal=str;
GHAssertEqualStrings(obj.goal,@“你好”,无);
}
@结束

Ld/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine cscchzscengbcmeyzxlkbhumdn/Build/Products/Debug iphonesimulator/Tests.app/Tests normal i386 cd/Users/dlwhitehurst/Development/Coding/Objective-C/iPad/machine setenv MACOSX_部署_目标10.6 setenv PATH“/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/bin:/usr/sbin:/sbin” /开发者/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2-arch i386-isysroot/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk-L/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine csccchzscencycmcmeyzxlkbhumdn/Build/Products/Debug iPhoneSimulator-F/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine cscchzscengbcmeyzxlkbhumdn/Build/Products/Debug iphonesimulator-F/Users/dlwhitehurst/Development/Frameworks-filelist/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Debug-iphonesimulator/Tests.Build/Objects-normal/i386/Tests.LinkFileList-mmacosx-version-min=10.6-ObjC-all\u load-Xlinker-ObjC\u-abi-version-Xlinker 2-framework-CoreData-framework-framework-GHUnitIOS-framework-UIKit-framework基础框架核心图形-O/UpLS/DLWEEHEST/库/开发者/ XCODE/派生数据/机器CSCCHZSCNGBMCMYZXLKBHDND/构建/产品/调试IPHONSIMULUTION/TEST。APP/Test

架构i386的未定义符号: “_OBJC_CLASS_$_Goal”,引用自: ControllerTests.o中的objc类引用 ld:未找到架构i386的符号 collect2:ld返回1退出状态

临时解决方案:

选择目标“测试”。选择“编译源代码”。然后添加“Goal.m”,您将运行测试

我也很困惑。我觉得这太疯狂了。
相同:

更好的解决方案可能是在为GHUnit test创建目标的同时复制目标,而不是创建新的目标