Set build variable in scheme instead of target

Viewed 2287

I am currently working on an iOS project in XCode that uses configurations to specify the different API environments my app can connect to. Additionally, I use targets to override one of my project configuration's user-defined values to specify a particular configuration file to use in the app. However, this is the only value that changes in the target. I work with multiple different configuration files (maybe 10 to 20 at a time) and creating a new target for each file to update one value seems clunky.

My question: Is there a way to pass this one value in from the scheme instead of setting it in the target?

I have seen that there is a pre-build script that can be run but I have not yet had any success exporting environment variables.

CONFIG_FILE="My Config File"
export CONFIG_FILE

I have also seen that some people have had success using PlistBuddy to write the values into the info.plist file during the pre-build phase of the scheme. This may be an option as well although it would require I redo a lot of my build process. I wanted to see if there was any other options before heading down this path.

Thanks for the help.

1 Answers
Related