gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 21:50:04 26 4
gpt4 key购买 nike

我正在尝试运行 GHUnit 测试,以测试 setter 实际上是否适用于我的应用程序中的 NSManagedObject 对象。我的应用程序称为 Machine,而我的 GHUnit 目标称为 Tests。我已将 Machine 添加为 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);

}

@结尾

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/库/开发者/Xcode/DerivedData/Machine-cscchzscengbcmcmemyzxlkbhumdn/Build/Products/Debug-iphonesimulator -F/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Debug-Phonesimulator -F/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Builds/Products/Products dlwhitehurst/Development/Frameworks -filelist/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Intermediates/Machine.build/Debug-iphonesimulator/Tests.build/Objects-normal/i386/Tests. 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/Debu g-iphonesimulator/Tests.app/Tests

架构 i386 的 undefined symbol :
“_OBJC_CLASS_$_Goal”,引用自:
ControllerTests.o 中的 objc-class-ref
ld:找不到架构 i386 的符号
collect2: ld 返回 1 个退出状态

最佳答案

临时解决办法:

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

我也很困惑。我觉得这很疯狂。
同:Linking error for unit testing with XCode 4?

关于ios4 - 应用程序类的 GHUnit 链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6397763/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com