title: iPhone unit testing: Symbols not found when calling custom code
body: <p>I'm trying to set up unit testing for my iPhone application. I followed the <a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html#//apple_ref/doc/uid/TP40007959-CH20-SW1" rel="nofollow noreferrer">Apple Unit Testing documentation</a> through and that woked fine, but as soon as I added another class in to that test, I get the following error:</p>
  
  <pre><code>  "_OBJC_CLASS_$_RootViewController", referenced from:
        __objc_classrefs__DATA@0 in AppDelegateTests.o
  ld: symbol(s) not found
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>The application itself is a basic navigation app with Core data for data storage.</p>
  
  <p>The unit test is as follows:</p>
  
  <pre><code>#import &lt;SenTestingKit/SenTestingKit.h&gt;
  #import &lt;UIKit/UIKit.h&gt;
  #import &lt;CoreData/CoreData.h&gt;
  
  #import "HSStabilityAppAppDelegate.h"
  #import "RootViewController.h"
  @interface AppDelegateTests : SenTestCase {
   HSStabilityAppAppDelegate *appDelegate;
  }
  @end
  
  
  @implementation AppDelegateTests
  // all code under test must be linked into the Unit Test bundle
  
  
  #pragma mark -
  #pragma mark Set up and tearDown
  
  #if APPLICATION_TESTS
  - (void) setUp {
   appDelegate = (HSStabilityAppAppDelegate *)[[UIApplication sharedApplication] delegate];
   STAssertNotNil(appDelegate, @"Cannot find the application delegate.");
  }
  
  - (void) tearDown {
   [appDelegate release];
  }
  
  #else
  
  #endif
  
  
  #pragma mark -
  #pragma mark Tests
  
  #if APPLICATION_TESTS
  
  - (void) testRootViewIsOnTop {
   id topViewControllerClass = [[appDelegate.navigationController topViewController] class];
   id rootViewControllerClass = [RootViewController class];
   STAssertEquals(topViewControllerClass, rootViewControllerClass, @"Root view controller was not the top class");
  }
  
  #endif
  
  @end
  </code></pre>
  
  <p>If I comment out the id rootViewControllerClass line then the program links correctly.
  Also, this only occurs when building against the device target, I don't have any problems if building against the simulator (probably given that application tests don't work on the simulator).</p>
  
  <p>Can anyone help solve this basic and very infuriating problem?</p>