Automatically incrementing iOS Build number?

We have a local build process that automatically updates the iOS build number before building, so that the same build number is never used twice. There is a version.txt in our repo where we read the build number, increment it, set the PlayerSettings.iOS.buildNumber, then save the new number.
Cloud Build however, does not retain the version.txt change between subsequent builds, so we have every Cloud Build with the same build number.

Look thing through the UnityCloudBuildManifest, I notice a buildNumber key that seems to be incremented every time. Is there a way that we can set Cloud Build to to automatically increment PlayerSettings.iOS.buildNumber?

It doesn’t matter if our our local build number and the cloud build numbers are synced, but we would like our Cloud Builds to have incremented build numbers the same as our local builds do. We were hoping that we could replace our local build process with Cloud Build, and this is the last hold out.

I thought about setting PlayerSettings.iOS.buildNumber from the UnityCloudBuildManifest buildNumber in a pre-export method, but it looks like the manifest isn’t accessible then.

Does anyone have any ideas on getting the PlayerSettings.iOS.buildNumber to increment from within Cloud Build?

I’m using this script that asks UCB for the latest build number and assign it to the XCode project.
It works both locally (so no need for a text file) and on UCB.
Haven’t made the Android part for now but I will someday.

  • Put this file in Assets/Editor/
  • fill the 5 string at the top (4 if you are not using Android) and you’re good to go.

Hope that’s help.

2 Likes

Hmm, I was hoping Cloud Build would have a simple way to do it, but I think this will suffice.
Thanks.

The build manifest should be accessible during pre-export. See usage here: Unity Build Automation

2 Likes

I finally got back to this and tried dannyb’s solution. It totally worked. I didn’t realize that there were two ways to handle the build manifest. Thanks a bunch.

1 Like

@dannyd is there a way to get the BuildManifestObject buildNumber value at runtime after the pre-export? We don’t want to alter
PlayerSettings.bundleVersion to have the build number because it triggers a re-review at Apple. We’d like to get the buildNumber at runtime though for debugging things in the field.

Yes, you can get it from the cloud build manifest file. When you build with cloud build this file gets put into your resources folder and has lots of useful info you can display (e.g. on the pause menu for QA) Unity Build Automation

Can anyone provide more detail for the denser among us? How do you get it from the manifest? Where do you put it?

I wrote an example script of how to do this here ( Get build number - Unity Services - Unity Discussions ) if you want to have a look.