To do this, you need to have a variable inside the build settings, which seems simple, but it is not. If you set the environment variable through a Pre- or Post-step in an application or testing scheme, it looks like it will not be found here. Build settings, after all, happen before the build. The same applies to the preprocessor macro, although doing this with xcodebuild and passing a custom option may work.
The only way I know is to use the xcconfig file. Create it and apply it (at least) to the test target. Content should include the following: THINGUNDERTEST=FooBar
Now in the settings of your project, in the xcconfig file or in the project file, set BUNDLER_LOADER to: $(BUILT_PRODUCTS_DIR)/$(THINGUNDERTEST).app/$(THINGUNDERTEST)
It will work. Now you can change THINGUNDERTEST using various means and get at least some dynamic behavior. This may work for you or may not, depending on your needs, but it is probably just a starting point.
source share