How to create variables for use in Xcode build settings values?

Xcode4Xcode5

Xcode4 Problem Overview


XCode has a number of built-in variables that are used for convenience in Build Settings, for example "$(PRODUCT_NAME)" or "$(CURRENT_ARCH)".

Can I define my own variables? How / where?

Xcode4 Solutions


Solution 1 - Xcode4

In XCode 5 this has changed slightly.

  1. Select the project or target in the left side of the editor
  2. Go to the Editor menu in the top menu bar
  3. Select "Add Build Setting" and then "Add User-Defined Build Setting"

enter image description here

Solution 2 - Xcode4

Create a user-defined build setting. To create one in Xcode 4 select your project from the project navigator to open the project editor. Select your project or target from the left side of the editor. Click the Build Settings button at the top of the editor. Click the Add Build Setting button at the bottom of the editor and choose Add User-Defined Setting.

Solution 3 - Xcode4

It's at the top of the build settings panel in Xcode 10.

enter image description here

Solution 4 - Xcode4

User-defined setting can be added in Xcode as specified below:

Xcode 4.x :

Select PROJECT / TARGETS -> “Add Build Setting” (option present in bottom-right corner of Xcode) -> “Add User-Defined Setting”

enter image description here

Xcode 5.x :

Select PROJECT / TARGETS -> Editor menu -> “Add Build Setting“ -> “Add User-Defined Setting”

enter image description here

This will add User-defined setting. Enter key-value for setting.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBen FlynnView Question on Stackoverflow
Solution 1 - Xcode4Jon DeokuleView Answer on Stackoverflow
Solution 2 - Xcode4Swift Dev JournalView Answer on Stackoverflow
Solution 3 - Xcode4Yousef HamzaView Answer on Stackoverflow
Solution 4 - Xcode4Jayprakash DubeyView Answer on Stackoverflow