How to change build configuration in Xcode Cloud pipeline?

741 views Asked by At
  • For CI/CD we are using Xcode Cloud.
  • My application have three build configurations: Debug, Stage and Release.
  • In the Xcode Cloud we have set up two pipelines: Stage and Release.
  • Default build configuration for archive state is Release. Image attached

When we are triggering Stage pipeline it executes archive with Release configuration. Here is no the way to set build configuration for pipeline.

How to change active build configuration in Xcode Cloud pipeline?

enter image description here

enter image description here

2

There are 2 answers

0
user8680821 On BEST ANSWER

One thing you can do is to create another scheme, like BSG-Stage and set the build configuration of it to Stage (instead of release). Then you can add a separate workflow in XCode cloud for the staging and select the "BSG-Stage" scheme.

0
mjgalindo On

XCode cloud allows you to have scripts running before doing the actual compilation.

In either ci_post_clone.sh or ci_pre_xcodebuild.sh it should be possible to do a simple modification of the scheme you are building to have a different default build config.

Something like this:

sed -i '' -e 's/buildConfiguration = ".*"/buildConfiguration = "'$CHOSEN_CONFIG'"/g' projectName.xcodeproj/xcshareddata/xcschemes/$CI_XCODE_SCHEME.xcscheme

CHOSEN_CONFIG can be set as an environment variable in the XCode cloud workflow, so you can just create one workflow per desired build config type.

Note: this is hackish, prone to be broken at any time. You could parse the xml scheme file and modify the specific buildConfiguration you need, but even that could be broken in the future. Hopefully Apple will expose an official way to change the config soon.