fzf fzf - 6 months ago 31
iOS Question

Programmatically determine current target (run or test) in iOS project

Is there any way to programmatically determine if you are running code in the Test target vs the regular Run target while developing iOS applications?

I have the hack of checking if this variable is nil or not as it is only in my test target but this seems pretty hacky.

[[[NSProcessInfo processInfo] environment] objectForKey:@"XCInjectBundle"]

Answer

You should define proper value for "Preprocessor Macros" in Target Settings.

At the run time you can check it with ifdef sentence.

Comments