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.
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.
A related topic is discussed here. In my AppDelegates application:didFinishLaunchingWithOption: -method I have the following lines of code:
var testSetting = NSBundle(forClass: self.dynamicType).objectForInfoDictionaryKey("TEST_TARGET") as? String
println("Testtarget: \(testSetting)")
When run these line of code prints Testtarget: nil. However, adding the exact same lines of code in the TestClass setup-method renders the expected result of Testtarget: Optional("\"This is a test target\"")
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.
EDIT: Only typos