2

whenever i run the unit testing application to find whether appdelegate is there r not using the test suit

-(void)testAppDelegate
{
id app_delegate=[[UIApplication sharedApplication]delegate];
STAssertNotNil(app_delegate,@"delegate not found");
}

i got this error. Please help.

"_OBJC_CLASS_$_UIApplication", referenced from:

  objc-class-ref-to-UIApplication in Tests.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

skaffman
  • 398,947
  • 96
  • 818
  • 769
Pradeep
  • 37
  • 4
  • What sort of test is this and how are you running it? Apple's 'logic tests' are not run inside an application so you can't call `[UIApplication sharedApplication]` from such a test. – Jonah Jan 05 '11 at 04:57
  • Yes it is a "logic test",But i followed the apple's document steps to create this and the sample downloaded is running.I followed Moszi's answer, now i m not getting that error. but stil it shows no appdelegate is found. – Pradeep Jan 06 '11 at 05:46

1 Answers1

3

I believe this is a linker error and not a runtime error. You need to link the same frameworks that you use in your iPhone build target to your unit test target. Particularly this error indicates that the UIKit framework is not linked to your unit test target. (To be safe link UIKit, Foundation and CoreGraphics as well to your target).

You can do this, by expanding the Targets node in XCode, get info on your unit test target, and under the General tab, in the Linked Libraries you need to add these 3 frameworks ;)

Hope this helps, Moszi

Moszi
  • 3,236
  • 2
  • 22
  • 20