问题描述
我正在尝试运行一个GHUnit测试来测试一个setter实际上适用于我的应用程序中的NSManagedObject对象。我的应用程序名为Machine,我的GHUnit目标称为测试。我已将Machine添加为Tests目标的依赖项。我在测试中的目标称为目标。以下是代码和链接中的错误如下所示。
I'm trying to run a GHUnit test to just test that a setter actually works for a NSManagedObject object in my app. My app is called Machine and my GHUnit target is called Tests. I've added Machine as a dependency to the Tests target. My object in the test is called Goal. Here is the code and the error in the Link is shown below.
#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);
}
@end
Ld /Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator/Tests.app/Tests normal i386
cd / Users / dlwhitehurst / Development / Coding / Objective-C / iPad / machine
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin: / bin:/ usr / sbin:/ sbin
/Developer/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-cscchzscengbcmcmeyzxlkbhumdn / Build / Products / Debug-iphonesimulator -F / Users / dlwhitehurst / Library / Developer / Xcode / DerivedData / Machine -cscchzscengbcmcmeyzxlkbhumdn / Build / Products / Debug-iphonesimulator -F / Users / dlwhitehurst / Development / Frameworks -fileli st /Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Intermediates/Machine.build/Debug-iphonesimulator/Tests.build/Objects-normal/i386/Tests.LinkFileList -mmacosx-version-min = 10.6 -ObjC -all_load -Xlinker -objc_abi_version -Xlinker 2 -framework CoreData -framework GHUnitIOS -framework UIKit -framework Foundation -framework CoreGraphics -o / Users / dlwhitehurst / Library / Developer / Xcode / DerivedData / Machine-cscchzscengbcmcmeyzxlkbhumdn / Build / Products / Debug-iphonesimulator / Tests.app / Tests
Ld /Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator/Tests.app/Tests normal i386 cd /Users/dlwhitehurst/Development/Coding/Objective-C/iPad/machine setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/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-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator -F/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator -F/Users/dlwhitehurst/Development/Frameworks -filelist /Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Intermediates/Machine.build/Debug-iphonesimulator/Tests.build/Objects-normal/i386/Tests.LinkFileList -mmacosx-version-min=10.6 -ObjC -all_load -Xlinker -objc_abi_version -Xlinker 2 -framework CoreData -framework GHUnitIOS -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator/Tests.app/Tests
架构i386的未定义符号:
_ OBJC_CLASS _ $ _ Goal,引自:
objc-class在ControllerTests.o中的-ref
ld:找不到架构i386的符号
collect2:ld返回1退出状态
Undefined symbols for architecture i386: "_OBJC_CLASS_$_Goal", referenced from: objc-class-ref in ControllerTests.old: symbol(s) not found for architecture i386collect2: ld returned 1 exit status
推荐答案
临时解决方案:
选择目标测试。选择编译源。然后添加Goal.m,你将运行测试。
Select target "Tests". Select "Compile Sources". Then add "Goal.m", you will run tests.
我也很困惑。我觉得这很疯狂。
相同:
I'm also confused. I feel this is crazy.Same:Linking error for unit testing with XCode 4?
这篇关于应用程序类的GHUnit链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!