I attempted an iOS build using Unity Cloud Build successfully. I then attempted to add in a Pre-Export Method, but it keeps failing with no explanation.
After reading previous topics related to this, I believe the reason may be because the method can’t be found, but I’m not sure why that is. I don’t receive any of the Debug logs I manually added, which is another reason I think it can’t be found.
My code is as follows:
using UnityEngine;
using UnityEditor;
public class UnityCloudBuild : MonoBehaviour
{
public static void OnPreExportIOS()
{
Debug.Log("UnityCloudBuild - OnPreExportIOS started");
FileUtil.DeleteFileOrDirectory("Assets/StreamingAssets/Bundles");
FileUtil.DeleteFileOrDirectory("Assets/StreamingAssets/Bundles.meta");
Debug.Log("UnityCloudBuild - Going to Refresh");
AssetDatabase.Refresh();
}
}
This is saved within a script in my project, under Assets/Scripts/UnityCloudBuild/UnityCloudBuild.cs
And in the Advanced Options > Pre-Export I enter it as: UnityCloudBuild.OnPreExportIOS
The build has failed after about 2 hours both times, so it’s a bit frustrating not knowing why. Any suggestions would be great.
The docs also state that you optionally can add a parameter of type “UnityEngine.CloudBuild.BuildManifestObject”,
But i cant seem to be able to use that CloudBuild namespace. Any news about this?
On the cloud build page it uses the same example, which is a bit irritating.
Hi friends, does that manifest provide the build number specifically listed in the cloud build history? Or is it whatever is set within the project. I would prefer to automatically use the cloud build numbering system.
Yes the manifest provides the build number that will match the number in the Unity Cloud Build history. It’s available as “buildNumber” in the manifest.
In both iOS and android
Advanced Options > Pre-Export I enter it as: AutoIncrementVersionCodeInCloudBuild.PreExport
Below are my codes
#if UNITY_CLOUD_BUILD
using System;
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class AutoIncrementVersionCodeInCloudBuild : MonoBehaviour
{
public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
{
string buildNumber = "";
buildNumber = manifest.GetValue<String>("buildNumber");
Debug.LogWarning("Prebuild launched build number to " + buildNumber);
DebugTool.ClientLog("Setting build number to " + buildNumber);
}
}
#endif