Search Unity

Change Cloud build number

Discussion in 'Unity Build Automation' started by marcV2g, Sep 6, 2016.

  1. marcV2g

    marcV2g

    Joined:
    Jan 11, 2016
    Posts:
    115
    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?
     
  2. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    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.
     
  3. marcV2g

    marcV2g

    Joined:
    Jan 11, 2016
    Posts:
    115
    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.
     
  4. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    1. Ya I wasn't suggesting that it would change the numbering in Unity Cloud Build, just that it would allow you to have control over the bundleVersionCode you are using for submitting to android store.
    2. The advanced feature guide in our support docs has info about the pre-export method (and there are several related threads in this forum with example code)
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    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:
    Code (CSharp):
    1. private static void IncrementBuildNumber(int amount)
    2.     {
    3.         // Load the PlayerSettings asset.
    4.         var playerSettings = Resources.FindObjectsOfTypeAll<PlayerSettings>().FirstOrDefault();
    5.  
    6.         if (playerSettings != null)
    7.         {
    8.             SerializedObject so = new SerializedObject(playerSettings);
    9.  
    10.             // Find the build number property.
    11.             var sp = so.FindProperty("AndroidBundleVersionCode");
    12.  
    13.             var currentValue = sp.longValue;
    14.  
    15.             sp.longValue = currentValue + amount;
    16.  
    17.             // Save player settings.
    18.             so.ApplyModifiedProperties();
    19.             AssetDatabase.SaveAssets();
    20.         }
    21.     }
    You can call this from your pre-export method and it will increment your build number. We use IncrementBuildNumber(1000);
     
    monstercouch likes this.
  6. marcV2g

    marcV2g

    Joined:
    Jan 11, 2016
    Posts:
    115
    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.
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    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.
     
  8. hikarusan

    hikarusan

    Joined:
    Jan 5, 2017
    Posts:
    9
    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?
     
  9. matiasticbits

    matiasticbits

    Joined:
    Jan 3, 2017
    Posts:
    30
    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.
     
  10. matiasticbits

    matiasticbits

    Joined:
    Jan 3, 2017
    Posts:
    30
    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?
     
  11. affinixy

    affinixy

    Joined:
    Nov 2, 2017
    Posts:
    13
    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?
     
  12. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    228
    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.
     
    n8zach likes this.
  13. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    228
    joaoborks and AdamBebko like this.
  14. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    704
    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.
     
    Last edited: Sep 21, 2021
  15. larskroll

    larskroll

    Joined:
    Dec 17, 2013
    Posts:
    52
    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

    upload_2024-3-12_14-22-24.png

    (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 ?