When to use .xcconfig files
Asked Answered
L

3

11

I have just set up three different configurations in my project for debug preview and release. No in Xcode there is an option to specify different .xconfig files per configuration. I am now wondering in what circumstances they should/could be used and what their advantages are over just editing the build settings per configuration.

Layfield answered 23/1, 2012 at 18:21 Comment(0)
F
9

Use xcconfig files if you find yourself changing the same build settings for each project you create. Place the build settings you're changing in the xcconfig file. By using a xcconfig file you can avoid editing those build settings every time you create a project.

Having the option to use different xcconfig files for each build configuration allows you to place the debug build settings you're constantly changing in one xcconfig file and place the release build settings you're changing in another xcconfig file. Use multiple xcconfig files if the build settings you're changing have different values for debug and release builds or if you change some build settings only for debug builds and other build settings only for release builds.

Foreigner answered 23/1, 2012 at 19:36 Comment(1)
Pro tip: you can use #include "shared.xcconfig_include" inside these files to include shared options in release/debug files.Mcnulty
P
5

It's not me who you asked about an example @Besi but I would like to explain why the BundleId change is useful at least for me.

When I have different requirements for "Development", "Ad Hoc", "App Store", for example I need to send Push Notifications, so the push certificate will be different depending on the version.

In this case I can make 3 different XCode schemes and depending on the chosen scheme, when compiling the bundle identifier will change so a different kind of version will result.

Add to this the fact you can use you xcconfig to choose the "Code Sign Identity", and practically every build setting you can imagine. This way is more correct than having different targets for each version and with different plist files and build settings, because you avoid duplication and you can customize the way the settings should override each other.

Sorry if this is very convoluted, I tried responding the original question in the process.

Perceptible answered 19/7, 2013 at 9:46 Comment(1)
How exactly do you change bundle identifier based on Xcode scheme? Pre-build actions?Diphyllous
M
2

One way I've used xcconfig files is to set up different BundleId's for iPhone apps. That way you can have different apps with different features/servers enabled. Very helpful. It involves using a variable name for the BundleId.

Marchak answered 23/1, 2012 at 22:31 Comment(1)
Could you maybe add an Example?Layfield

© 2022 - 2024 — McMap. All rights reserved.