Is there a way to change .xcconfig files per scheme in Xcode 9?

I currently have a project setup with one target and multiple build configurations (DEBUG, STAGING, RELEASE). Each build configuration has a corresponding .xcconfig file for the one target/scheme. I would like to keep the project at one target, and add a second scheme that would use a different set of .xcconfig files for the 3 build configurations. Is there a way to swap out those .xcconfig references at build time on a per-scheme basis without having to set up a separate target for the 2nd scheme?

1 answer

  • answered 2018-01-12 17:14 sfeuerstein

    OK I came up with this solution that will work with any CI setup that allows you to execute a post-clone / pre-build script:

    I created 3 .xcconfig files called Default-DEBUG.xcconfig, Default-STAGING.xcconfig, and Default-RELEASE.xcconfig. Those are then associated with the target's configurations via Xcode.

    In the post-clone phase I have a script that takes the name of the scheme, looks for a matching .xcconfig file (named the same as the scheme), and copies it over to replace the appropriate Default one.