title: How do I reach Test Target Bundle Plist-file from production code under the Test Target?
body: <p>I need to flag certain test-specific situations from production code, and since precompiled macros no longer exist in swift (and since the Other Swift Flags seems to work on a target basis, but not on a test-target specific basis) I thought I could use the test plist to access properties only available during testing.</p>
  
  <p>If this strategy works, I need to access my test target plist file from the AppDelegates application:didFinishLaunchingWithOption: -method. I've a Property called TEST_TARGET in the plist, which for this example is a string.</p>
  
  <p><img src="https://i.stack.imgur.com/uE9Ef.png" alt="enter image description here"></p>
  
  <p><a href="https://stackoverflow.com/questions/1879247/why-cant-code-inside-unit-tests-find-bundle-resources">A related topic is discussed here</a>. In my AppDelegates application:didFinishLaunchingWithOption: -method I have the following lines of code:</p>
  
  <pre><code>var testSetting = NSBundle(forClass: self.dynamicType).objectForInfoDictionaryKey("TEST_TARGET") as? String
      println("Testtarget: \(testSetting)")
  </code></pre>
  
  <p>When run these line of code prints <strong>Testtarget: nil</strong>. However, adding the exact same lines of code in the TestClass setup-method renders the expected result of <strong>Testtarget: Optional("\"This is a test target\"")</strong></p>
  
  <p>It seems to me that NSBundle(forClass: self.dynamicType) does not return the testBundle when called from the AppDelegate, which to some extent can be logical, given that the AppDelegate class is in the mainBundle. But then, is there some way in which I can reach the testPlist from the production code? And can this be done without breaking any fundamental principles of testing and code architecture.</p>
  
  <p>EDIT: Only typos</p>