Search Unity

Automatically incrementing iOS Build number?

Discussion in 'Unity Build Automation' started by MatValadez, Jan 11, 2017.

  1. MatValadez

    MatValadez

    Joined:
    Dec 19, 2012
    Posts:
    5
    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?
     
  2. ophilbert

    ophilbert

    Joined:
    Dec 3, 2014
    Posts:
    47
    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.
     
    Haze-Games and meta-ben like this.
  3. MatValadez

    MatValadez

    Joined:
    Dec 19, 2012
    Posts:
    5
    Hmm, I was hoping Cloud Build would have a simple way to do it, but I think this will suffice.
    Thanks.
     
  4. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    shaepe and TobyKaos like this.
  5. MatValadez

    MatValadez

    Joined:
    Dec 19, 2012
    Posts:
    5
    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.
     
    SophiaC likes this.
  6. herenow

    herenow

    Joined:
    Jan 11, 2017
    Posts:
    3
    @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.
     
  7. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
  8. Grizznix

    Grizznix

    Joined:
    Oct 25, 2015
    Posts:
    1
    Can anyone provide more detail for the denser among us? How do you get it from the manifest? Where do you put it?
     
  9. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089