Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration dependent value in Info.plist file

Tags:

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"?

like image 520
Besi Avatar asked Jan 23 '12 12:01

Besi


People also ask

How do I edit info plist files?

All you have to do is click on the blue project icon -on top of the left- and go to the “Build Settings” tab, search “Info. plist” and choose “Info. plist File” section. Then change the information of the section from your folder's name.

How do I open Info plist as a source code?

Press ⌘+⇧+o to get the Quick Open Dialog. Enter name of property list file e.g. " info. plist " and press "Enter" Open "Version Editor" -> Property List File is shown as source code.

What is the info plist and what is the usage of it?

The Info. plist file contains critical information about the configuration of an iOS mobile app—such as iOS versions that are supported and device compatibility—which the operating system uses to interact with the app. This file is automatically created when the mobile app is compiled.

How do I view info plist in XML?

You can see the XML version of the plist by opening the file in a text editor such as Sublime Text or Atom. *Edit - you can also right click the Info.


1 Answers

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.

like image 176
Youraj Avatar answered Sep 23 '22 06:09

Youraj