Configuration dependent value in Info.plist file

Besi picture Besi · Jan 23, 2012 · Viewed 14k times · Source

I have three configurations in my iOS project:

  1. Debug
  2. Adhoc
  3. Release

Now I want to change the name of the App as follows:

  1. MyAppDebug
  2. MyAppAdhoc
  3. MyApp (Note that this one does not have a suffix)

Is there a way I can easily achieve this in Xcode with some type of "compiler-if-else-macro-thing"?

Answer

Youraj picture Youraj · Aug 9, 2013

Changing display name of app for respective configurations: one way to achieve this is by using the same info plist file that you have.

Part 1: create an user defined variable

  1. Click on target project file.
  2. Then at bottom right corner locate button "+" Add Build Setting.
  3. Click that button "Add Build Setting" and select "Add User-Defined Setting" enter name for New Setting as for ex: "BUNDLE_DISPLAY_NAME".
  4. Expand this new setting to see the configurations under it. Give the desired name to be displayed for each configuration. For ex: Debug -> MyAppDebug

Part 2: use it

  1. Select your appname-info.plist file.
  2. Locate key "Bundle Display Name" and value to it should be this new user defined variable ${BUNDLE_DISPLAY_NAME}

Then for appropriate configuration it will select name from BUNDLE_DISPLAY_NAME variable in build settings.