Created
July 6, 2019 11:58
-
-
Save acarabott/132752e900ec37efa0397ef8fbbf6b5d to your computer and use it in GitHub Desktop.
Unity iOS Build Number Incrementer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEditor; | |
using UnityEditor.Callbacks; | |
using UnityEngine; | |
public static class iOSBuildIncrementer | |
{ | |
[PostProcessBuild] | |
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) | |
{ | |
if (target == BuildTarget.iOS) | |
{ | |
int buildNumber; | |
if (int.TryParse(PlayerSettings.iOS.buildNumber, out buildNumber)) | |
{ | |
buildNumber++; | |
} | |
else | |
{ | |
buildNumber = 0; | |
} | |
Debug.Log($"Build Number: ${buildNumber}"); | |
PlayerSettings.iOS.buildNumber = buildNumber.ToString(); | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment