Configuration Handling in Xcode

Abhimuralidharan
2 min readMar 15, 2017

--

Typically, Xcode starts us out with two configurations; Debug and Release. You will find them in your project’s info page. You can create more configurations like Beta, Staging etc on demand. You can edit these configurations as required (Just create a duplicate of release or debug versions and rename it appropriately).

You can then add swift compiler flags so that we can check the current configuration through code.

To do that, goto Project (not target)Build settingsSwift CompilerCustom flags → Other swift flags section and edit the different configuration flags. Add the flags using the syntax “ -D <flag_name>”.

NOTE: if you are not seeing Other swift flags section, you will be in the basic build settings mode. Just select ‘All’ as in the screenshot below.

Now, we can use these flags in code to check the current configuration like:

Now, For changing current scheme, goto your TargetEdit scheme . Then under the info tab, click and change the build configuration as required.

Suppose if you are having different constants for release and debug app, follow the above pattern of configuration management which helps in minimising the errors.

ENJOY!!

If you enjoyed reading this post, please share and recommend it so others can find it 💚💚💚💚💚💚 !!!!

--

--