title: Xcode Unit Tests - Link error when building for device only
body: <p>My application unit tests build and test when running in the simulator, but fails with a linker error when building and testing to device.</p>
  
  <p>On my application target I've set the following build settings:</p>
  
  <pre><code>DEPLOYMENT_POSTPROCESSING = NO
  GCC_SYMBOLS_PRIVATE_EXTERN = NO
  </code></pre>
  
  <p>On my unit test I've set the following build settings:</p>
  
  <pre><code>BUNDLE_LOADER = $(BUILT_PRODUCTS_DIR)/&lt;app name&gt;.app/&lt;app&gt;
  TEST_HOST = $(BUNDLE_LOADER)
  </code></pre>
  
  <p>The linker error is:</p>
  
  <pre><code>Undefined symbols for architecture armv7s:
  "_&lt;An NSString * const&gt;", referenced from:
        -[UnitTestClassA setUp] in UnitTestClassA.o
  "_&lt;Another NSString * const&gt;", referenced from:
        -[UnitTestClassB helperMethod:] in UnitTestClassB.o
        -[UnitTestClassB anotherHelperMethod:] in UnitTestClassB.o
  ld: symbol(s) not found for architecture armv7s
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>... I have "continue after building errors" turned on in Xcode's preferences, but I don't receive a ton of linker errors complaining about NSString * const's. If I'm doing something wrong, then would expect more link errors than the handful I'm getting since I use string constants throughout my production code.</p>
  
  <p>I'm creating my string constants like this:</p>
  
  <p>.h file...</p>
  
  <pre><code>extern NSString * const ReallyGoodString;
  </code></pre>
  
  <p>.m file...</p>
  
  <pre><code>NSString * const ReallyGoodString = @"This string is great!";
  </code></pre>
  
  <p>... the .m file is production code, and part of my application target, and so I do not have to link it into the unit test bundle.</p>
  
  <p><em>So, what is going on here? Why does this work just fine in the simulator and not on device?</em></p>
  
  <p>I've posted a <a href="https://github.com/evandelaney/StackOverflow-17158101" rel="noreferrer">sample project to Github</a> that illustrates the problem. You can see in the sample project that this problem is inconsistent: some symbols link just fine others do not.</p>