So cloud build auto increments the version number but if I have two build profiles (dev/prod) I have duplicate version numbers that is not allowed by the android store.
Is there any way I can manually change or synchronise them?
So cloud build auto increments the version number but if I have two build profiles (dev/prod) I have duplicate version numbers that is not allowed by the android store.
Is there any way I can manually change or synchronise them?
The bundleVersionCode is only set automatically by Cloud Build when itās currently 0. So, you can either change the number manually in your Player Settings and check that in to source control, or set up a pre-export method to adjust the number at the start of the build.
1: So far it seem like what Version Code I set in the editor has no effect on cloud builds incremental numbering.
2: Do you have any tutorials for the pre-export method, I am interested in build scripts but have never gotten them to work on cloud build.
As far as i know, the build version has no effect on the actual produced .apk version. Unity cloud build will simply pick up whatever version you have defined in your project (saved to player settings).
We are building 2 different APKs (ARM and x86), and we version them automatically using a simple scheme that x86 builds are always 1000 + ARM version.
Hereās the code we use:
private static void IncrementBuildNumber(int amount)
{
// Load the PlayerSettings asset.
var playerSettings = Resources.FindObjectsOfTypeAll<PlayerSettings>().FirstOrDefault();
if (playerSettings != null)
{
SerializedObject so = new SerializedObject(playerSettings);
// Find the build number property.
var sp = so.FindProperty("AndroidBundleVersionCode");
var currentValue = sp.longValue;
sp.longValue = currentValue + amount;
// Save player settings.
so.ApplyModifiedProperties();
AssetDatabase.SaveAssets();
}
}
You can call this from your pre-export method and it will increment your build number. We use IncrementBuildNumber(1000);
Do you use cloud build? I am just wondering how the increment would work since it never saves the new value back to the repository.
Yes, we use cloud build.
We donāt upload every build to the store, so the version doesnāt have to keep changing.
When we have a build thatās ready to be uploaded to Google play, we increment the version and submit that to source control.
In case we need a new build, we change the version again and push that to source control again.
So if I set my build version number in my player setting to 0, the cload build will auto increment to the cloud build number?
Should the version code incrementing still work in this way? Since we have version code set to 1 and still Unity cloud build increments the version code on every build.
After setting the version code higher than 1 the auto increment seemed to stop. Maybe the default version code has been set to 1 or something?
I set the bundle version to 0, it works for Google play, it auto increase the number using cloud build number.
But on itunesconnect, it will not work with 0.
Is there a work around?
Hi @dannyd , does UCB for iOS work the same way as Android? Iād like to set the āBuildā to be the same as cloud build number. @affinixy said it didnāt work on ios.
Hey, I found out that incrementing build number was actually documented on the Unity manual webpage. It uses Pre-export method.
Find out more :
https://docs.unity3d.com/Manual/UnityCloudBuildPreAndPostExportMethods.html
https://docs.unity3d.com/Manual/UnityCloudBuildManifestAsScriptableObject.html
Hello!
So when using UCB to generate Android builds, the build number auto increments. Every AAB uploaded to Google Play is showing an increasing build number.
But with iOS it does not, even if it is set to 0 (as mentioned above). Every upload to App Store Connect is showing a build number of 0.
Could someone advise if this is a bug or by design please?
It would be great to have some consistency across platforms for a simple feature like this.
I experience this as well. Can Unity please provide an answer?
My understanding: I can put my version number in playersettings, but I should let Build be 0

(from iOS tab in playersettings)
Yet, when I do this, I get the following error from the build upload :
ERRORS:
[error] 2024-03-12 13:13:02.035 *** Error: Error uploading ā/opt/workspace/workspace/kongo-interactive.alfie-atkins.default-ios/.build/last/default-ios/build.ipaā.
[error] 2024-03-12 13:13:02.035 *** Error: The provided entity includes an attribute with a value that has already been used The bundle version must be higher than the previously uploaded version: ā9ā. (ID: 4bc84544-e860-4874-b296-7a4ed7908579) (-19232)
[error] NSUnderlyingError = āError Domain=IrisAPI Code=-19241 "The provided entity includes an attribute with a value that has already been used" UserInfo={status=409, detail=The bundle version must be higher than the previously uploaded version., source={\n pointer = "/data/attributes/cfBundleVersion";\n}, id=4bc84544-e860-4874-b296-7a4ed7908579, code=ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE, title=The provided entity includes an attribute with a value that has already been used, meta={\n previousBundleVersion = 9;\n}, NSLocalizedDescription=The provided entity includes an attribute with a value that has already been used, NSLocalizedFailureReason=The bundle version must be higher than the previously uploaded version.}ā;
[error] āiris-codeā = āENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATEā;
The error goes away, if I manually update Build to latest build number +1.
What am I doing wrong ?