"_OBJC_CLASS _ $ _ viewsampleViewController" referenced by:

I am creating a view controller view viewplepleController .. And it has two methods setname and getname .. I am creating a test file for this view controller. my test object name is newTestCase and the method name is testName.

#import "newTestCase.h" #import "viewsampleViewController.h" @implementation newTestCase 

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]; } 

when i built i got an error

  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 

plz help me

0
objective-c iphone unit-testing
Dec 22 '10 at 5:23
source share
5 answers

This linker problem appears due to architecture and dependency . Usually, when we add some files to our project from other sources, do not install the exact dependency. This compiler generates a linker error. I solved this problem by following these steps:

  • Choose a target
  • Assembly phase selection
  • Select compilation sources
  • Select the + icon
  • Select the .m file for which you receive an error, and add it.
  • Clean the assembly and run it again.
+19
Jul 19 2018-12-12T00:
source share
β€” -

This is a linker error, add viewmpleViewController.m to the test target. Please run the class names in uppercase, make everything more readable.

+14
Dec 22 2018-10-12T00:
source share

Somehow the viewsapleViewController.m file is not compiled. Make sure its part of the project.

+2
Dec 22 '10 at 5:45
source share

I had the same problem when I made some changes to the sources of the project. All .m were changed to .mm, and for some reason no specific class was added to Link Binary With Libraries that had problems, but was in Copy Bundle Resources. After I changed this, it worked.

So here is what I did:

1) Click on the blue project tab in the upper left of Xcode. 2) Go to the "GOALS" option. 3) Click on the "Build Phases" tab. 4) Go to the "Copy package resources" section. 5) Find the implementation file (.m, .mm) and delete it by clicking the minus (-) option. 6) Go to the "Compile Sources" section and click the plus (+) button and add this implementation file. 7) Compile and hit him, brother, you will go well.

Hope this helps. Greetings.

0
Mar 11 '13 at 12:09 on
source share

Adding .m files to the application directly to the test target solves the problem, it is redundant and not needed. Follow the steps described here with two bits of Lab to make it work. To summarize, make sure your ...

  • test target Bundle Loader build configuration points to your application package.
  • test target Test Host assembly setup points to your application package.
  • Symbols Hidden by Default : NO .
0
Mar 13 '14 at 3:35
source share



All Articles