问题描述
我创建了一个视图控制器viewsampleViewController..它有两个方法setname和getname ..我为该视图控制器创建了一个测试用例.我的测试用例名称是newTestCase,方法名称是testName.
i create a view controller viewsampleViewController.. And it has two method setname and getname.. i create a testcase for that view controller. my testcase name is newTestCase and method name is testName.
#import "newTestCase.h"
#import "viewsampleViewController.h"
@implementation newTestCase
在我的testName方法中,
in my testName method,
-(void)testName{
NSString *b=@"hello";
v =[[viewsampleViewController alloc] init];
STAssertNotNil(v,@"v doesnt created");
[v setuname:@"hello"];
NSString *a=[v getuname];
STAssertEquals(b,a,@"error:name not equal");
[v release];
}
-(void)setUp{
v=[viewsampleViewController alloc];
}
-(void) tearDown{
[v release];
}
建造时出现错误
Ld "build/Debug-iphoneos/Unit test.octest/Unit test" normal armv6
cd /Users/anande/Documents/viewsample
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1.3
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -bundle -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -L/Users/anande/Documents/viewsample/build/Debug-iphoneos -F/Users/anande/Documents/viewsample/build/Debug-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk/Developer/Library/Frameworks -filelist "/Users/anande/Documents/viewsample/build/viewsample.build/Debug-iphoneos/Unit test.build/Objects-normal/armv6/Unit test.LinkFileList" -dead_strip -framework Foundation -framework SenTestingKit -miphoneos-version-min=3.1.3 -o "/Users/anande/Documents/viewsample/build/Debug-iphoneos/Unit test.octest/Unit test"
Undefined symbols:
"_OBJC_CLASS_$_viewsampleViewController", referenced from:
__objc_classrefs__DATA@0 in newTestCase.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
请帮助我
推荐答案
出现此链接器问题是由于体系结构和依赖性.实际上,当我们从其他来源向我们的项目中添加了一些文件,然后可能无法建立确切的依赖关系.因此,编译器会生成链接器错误.我通过以下步骤解决了此问题:
This linker problem appears because of architecture and dependency.Actually when we add some files to our project from some other sources then there may not establish the exact dependency.So compiler generates the linker error.I solved this problem by following the steps:
- 选择目标
- 选择构建阶段
- 选择编译源
- 选择+图标
- 选择您遇到错误的.m文件并添加.
- 清理构建并再次运行.
这篇关于"_OBJC_CLASS _ $ _ viewsampleViewController",引用自:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!