-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathIosBuilder.cs
More file actions
60 lines (52 loc) · 1.88 KB
/
Copy pathIosBuilder.cs
File metadata and controls
60 lines (52 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#nullable enable
using System;
using UnityEditor;
using UnityEngine;
namespace Immutable.Audience.Samples.SampleApp.Editor
{
// Invoked by CI via:
// Unity -batchmode -buildTarget iOS \
// -executeMethod Immutable.Audience.Samples.SampleApp.Editor.IosBuilder.Build \
// -quit
//
// Optional CLI arg:
// --buildPath <path> Output directory for the Xcode project (default: Builds/iOS)
internal static class IosBuilder
{
private const string DefaultBuildPath = "Builds/iOS";
public static void Build()
{
string buildPath = GetArgValue("--buildPath") ?? DefaultBuildPath;
var options = new BuildPlayerOptions
{
scenes = new[] { "Assets/SampleApp/Scenes/SampleApp.unity" },
locationPathName = buildPath,
target = BuildTarget.iOS,
targetGroup = BuildTargetGroup.iOS,
options = BuildOptions.None,
};
Debug.Log($"[IosBuilder] Building Xcode project → {buildPath}");
var report = BuildPipeline.BuildPlayer(options);
var summary = report.summary;
if (summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
{
Debug.Log($"[IosBuilder] Build succeeded ({summary.totalSize / 1024 / 1024} MB).");
}
else
{
Debug.LogError($"[IosBuilder] Build failed: {summary.totalErrors} error(s).");
EditorApplication.Exit(1);
}
}
private static string? GetArgValue(string flag)
{
var args = Environment.GetCommandLineArgs();
for (int i = 0; i < args.Length - 1; i++)
{
if (args[i] == flag)
return args[i + 1];
}
return null;
}
}
}