I just switched over to Xcode 4 and I'm having trouble working with .xcconfig files for build settings. My targets that already had files assigned in Xcode 3 are all set up - a column titled Config.file shows up in the Levels view of Build Settings. But I can't figure out how to edit the columns in this view or where to put an .xcconfig file to attach it to a new target. I've looked online and haven't found an answer. Anybody know how to do this?
Asked
Active
Viewed 3.6k times
2 Answers
109
Pick File | New, choose Other and "Configuration Settings File", this gets you a new .xcconfig file.
Then click on the project on the upper left in the file browser (the same place where you get to build settings), click on the project again in the second-to-left panel, and click on the Info tab at the top of the inner panel.
There, you can choose "Based on Configuration File" for each of your targets for each of your configurations (debug, release, etc.)
-
6Just in case Xcode doesn't do it for you, the .xcconfig file needs to be added to the project before it can be used as a Configuration File. – Matt Connolly Oct 22 '11 at 04:10
-
1Can I put add variables like "API_URL" in the configuration file? In that case, how do I access them using swift? – Simon Bengtsson May 21 '15 at 22:40
-
i have two variables in .xcconfig. how do i get value for different tragets? – Nagarjun Mar 03 '16 at 07:25
58
Great answer from Mike Kale. If the description was not clear enough, here is a screenshot.

allprog
- 16,540
- 9
- 56
- 97
-
one thing i don't understand is this: when you copy over a config file to the project.. you get prompted to click on each project that you wish the config file to apply to.. but then in the above screenshot.. there is a dropdown beside the project file *and* a dropdown beside *each* target.. so if I selected all targets in the first step.. so i still have to assign it to each target drop down menu? – abbood May 03 '14 at 08:05
-
1the answer is the latter (ie you still have to assign the config file for *each* target..) – abbood May 03 '14 at 08:09