66

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?

2 Answers 2

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.)

3
  • 6
    Just 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. Oct 22, 2011 at 4:10
  • 1
    Can I put add variables like "API_URL" in the configuration file? In that case, how do I access them using swift? May 21, 2015 at 22:40
  • i have two variables in .xcconfig. how do i get value for different tragets?
    – Nagarjun
    Mar 3, 2016 at 7:25
58

Great answer from Mike Kale. If the description was not clear enough, here is a screenshot.

xcconfig in the project configuration

2
  • 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 3, 2014 at 8:05
  • 1
    the answer is the latter (ie you still have to assign the config file for each target..)
    – abbood
    May 3, 2014 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.