Automatically incrementing version number with XCode Cloud?

XCode Cloud is successfully bumping our build number as explained in https://developer.apple.com/documentation/xcode/setting-the-next-build-number-for-xcode-cloud-builds

However, we are running into a minor nuisance where the version number still needs to be manually updated. Is there a best practice around automating this?

Here is the error we keep running into in XCode Cloud:

This bundle is invalid. The value for key CFBundleShortVersionString [1.0.0] in the Info.plist file must contain a higher version than that of the previously approved version [1.0.0]. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring

Here is the workflow causing the error:

  1. Let's assume the latest commit on the main branch is 1.0.0 and build number 1. So the current version string is 1.0.0 (1).
  2. We make a branch off of main and develop a new feature, then open a pull request. This creates 1.0.0 (2) automatically thanks to XCode Cloud
  3. The feature branch isn't ready in time for the release, so we submit 1.0.0 (1) to the App Store without the feature merged into main.
  4. The build gets approved and the app goes Ready for Sale.
  5. Now, any subsequent XCode Cloud build will fail since 1.0.0 needs to be incremented. This process to resolve this is manual - we need to determine a new version number that is greater than 1.0.0, make the commit to main and then pull that commit into each open branch.

The process works, but step (5) is a bit tedious. And if the engineer working on 1.0.0 (2) is different than the engineer releasing 1.0.0 (1), it causes unnecessary workfow inefficiencies.

By contrast, in our Android CI pipeline, the PR titles have MAJOR, MINOR, or PATCH in them, and the CI process automatically determines the next version number at the same time the build number is set. And since ad hoc distribution is allowed, it's ok if a PR branch is an earlier version than what is in main - builds will still run and the new version number will be determined at the time the branch is merged into main.

I'm curious if there is an Apple-idiomatic way to handle this workflow? Ideally if XCode Cloud could determine the next version, make the commit, and pull it into every open branch, this step could be automated.

Automatically incrementing version number with XCode Cloud?
 
 
Q