Skip to content

Commit

Permalink
Merge pull request #337 from immutable/test/ios-builder
Browse files Browse the repository at this point in the history
[DX-3413] test: ios builder
  • Loading branch information
nattb8 authored Oct 31, 2024
2 parents 9a7b0a5 + 33085e0 commit b3472f8
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 27 deletions.
3 changes: 2 additions & 1 deletion sample/Assets/Editor/MacBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ private static BuildPlayerOptions CreateBuildPlayerOptions(string buildPath, Bui
"Assets/Scenes/ZkEvmGetBalance.unity",
"Assets/Scenes/ZkEvmGetTransactionReceipt.unity",
"Assets/Scenes/ZkEvmSendTransaction.unity",
"Assets/Scenes/ImxNftTransfer.unity"
"Assets/Scenes/ImxNftTransfer.unity",
"Assets/Scenes/ZkEVMSignTypedData.unity"
},
locationPathName = buildPath,
target = BuildTarget.StandaloneOSX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,44 @@
using System;
using System.IO;

public class AndroidBuilder
public class MobileBuilder
{
private const string DefaultBuildPath = "Builds/Android/SampleApp.apk";
private const string DefaultAndroidBuildPath = "Builds/Android/SampleApp.apk";
private const string DefaultiOSBuildPath = "Builds/iOS";

static void Build()
{
BuildPlayer(DefaultBuildPath, BuildOptions.Development);
var platform = GetPlatformFromArgs();
string defaultBuildPath = platform == BuildTarget.Android ? DefaultAndroidBuildPath : DefaultiOSBuildPath;
BuildPlayer(defaultBuildPath, BuildOptions.Development, platform);
}

static void BuildForAltTester()
{
BuildPlayer(DefaultBuildPath, BuildOptions.Development | BuildOptions.IncludeTestAssemblies, true);
var platform = GetPlatformFromArgs();
string defaultBuildPath = platform == BuildTarget.Android ? DefaultAndroidBuildPath : DefaultiOSBuildPath;
BuildPlayer(defaultBuildPath, BuildOptions.Development | BuildOptions.IncludeTestAssemblies, platform, true);
}


private static void BuildPlayer(string defaultBuildPath, BuildOptions buildOptions, bool setupForAltTester = false)
private static void BuildPlayer(string defaultBuildPath, BuildOptions buildOptions, BuildTarget platform, bool setupForAltTester = false)
{
try
{
string buildPath = GetBuildPathFromArgs(defaultBuildPath);

BuildPlayerOptions buildPlayerOptions = CreateBuildPlayerOptions(buildPath, buildOptions);
BuildPlayerOptions buildPlayerOptions = CreateBuildPlayerOptions(buildPath, buildOptions, platform);

if (setupForAltTester)
{
SetupAltTester(buildPlayerOptions);
SetupAltTester(buildPlayerOptions, platform);
}

var results = BuildPipeline.BuildPlayer(buildPlayerOptions);

if (setupForAltTester)
{
// Clean up AltTester settings after build
AltBuilder.RemoveAltTesterFromScriptingDefineSymbols(BuildTargetGroup.Android);
AltBuilder.RemoveAltTesterFromScriptingDefineSymbols(platform == BuildTarget.Android ? BuildTargetGroup.Android : BuildTargetGroup.iOS);
RemoveAltFromScene(buildPlayerOptions.scenes[0]);
}
}
Expand All @@ -62,7 +66,20 @@ private static string GetBuildPathFromArgs(string defaultBuildPath)
return defaultBuildPath;
}

private static BuildPlayerOptions CreateBuildPlayerOptions(string buildPath, BuildOptions buildOptions)
private static BuildTarget GetPlatformFromArgs()
{
string[] args = Environment.GetCommandLineArgs();
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "--platform" && i + 1 < args.Length)
{
return args[i + 1].Equals("iOS", StringComparison.OrdinalIgnoreCase) ? BuildTarget.iOS : BuildTarget.Android;
}
}
return BuildTarget.Android; // Default to Android if no platform is specified
}

private static BuildPlayerOptions CreateBuildPlayerOptions(string buildPath, BuildOptions buildOptions, BuildTarget platform)
{
return new BuildPlayerOptions
{
Expand All @@ -74,17 +91,18 @@ private static BuildPlayerOptions CreateBuildPlayerOptions(string buildPath, Bui
"Assets/Scenes/ZkEvmGetBalance.unity",
"Assets/Scenes/ZkEvmGetTransactionReceipt.unity",
"Assets/Scenes/ZkEvmSendTransaction.unity",
"Assets/Scenes/ImxNftTransfer.unity"
"Assets/Scenes/ImxNftTransfer.unity",
"Assets/Scenes/ZkEVMSignTypedData.unity"
},
locationPathName = buildPath,
target = BuildTarget.Android,
target = platform,
options = buildOptions
};
}

private static void SetupAltTester(BuildPlayerOptions buildPlayerOptions)
private static void SetupAltTester(BuildPlayerOptions buildPlayerOptions, BuildTarget platform)
{
AltBuilder.AddAltTesterInScriptingDefineSymbolsGroup(BuildTargetGroup.Android);
AltBuilder.AddAltTesterInScriptingDefineSymbolsGroup(platform == BuildTarget.Android ? BuildTargetGroup.Android : BuildTargetGroup.iOS);
AltBuilder.CreateJsonFileForInputMappingOfAxis();

var instrumentationSettings = new AltInstrumentationSettings();
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion sample/Assets/Editor/WindowsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ private static BuildPlayerOptions CreateBuildPlayerOptions(string buildPath, Bui
"Assets/Scenes/ZkEvmGetBalance.unity",
"Assets/Scenes/ZkEvmGetTransactionReceipt.unity",
"Assets/Scenes/ZkEvmSendTransaction.unity",
"Assets/Scenes/ImxNftTransfer.unity"
"Assets/Scenes/ImxNftTransfer.unity",
"Assets/Scenes/ZkEVMSignTypedData.unity"
},
locationPathName = buildPath,
target = BuildTarget.StandaloneWindows64,
Expand Down
14 changes: 7 additions & 7 deletions sample/Assets/Scenes/SelectAuthMethod.unity
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 416242725}
m_HandleRect: {fileID: 416242724}
m_Direction: 0
m_Value: 1
m_Size: 1
m_Value: 0
m_Size: 0.9999999
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
Expand Down Expand Up @@ -1323,7 +1323,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 167431872}
m_HandleRect: {fileID: 167431871}
m_Direction: 2
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down Expand Up @@ -1673,8 +1673,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 905.59955, y: 0}
m_SizeDelta: {x: 1771.1991, y: 0}
m_AnchoredPosition: {x: 1259.3727, y: 0}
m_SizeDelta: {x: 2478.7454, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1661390145
MonoBehaviour:
Expand Down Expand Up @@ -1768,8 +1768,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 905.59955, y: 0}
m_SizeDelta: {x: 1771.1991, y: 0}
m_AnchoredPosition: {x: 1259.3727, y: 0}
m_SizeDelta: {x: 2478.7454, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1688502349
MonoBehaviour:
Expand Down
11 changes: 7 additions & 4 deletions sample/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.immutable.ImmutableSample
Standalone: com.immutable.unitysample
iPhone: com.immutable.Immutable-Sample
buildNumber:
Standalone: 0
VisionOS: 0
iPhone: 0
tvOS: 0
overrideDefaultApplicationIdentifier: 1
overrideDefaultApplicationIdentifier: 0
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 26
AndroidTargetSdkVersion: 33
Expand Down Expand Up @@ -232,7 +234,7 @@ PlayerSettings:
tvOSManualSigningProvisioningProfileID:
iOSManualSigningProvisioningProfileType: 0
tvOSManualSigningProvisioningProfileType: 0
appleEnableAutomaticSigning: 0
appleEnableAutomaticSigning: 1
iOSRequireARKit: 0
iOSAutomaticallyDetectAndAddCapabilities: 1
appleEnableProMotion: 0
Expand Down Expand Up @@ -529,7 +531,7 @@ PlayerSettings:
logObjCUncaughtExceptions: 1
enableCrashReportAPI: 0
cameraUsageDescription:
locationUsageDescription:
locationUsageDescription: Not used
microphoneUsageDescription:
bluetoothUsageDescription:
switchNMETAOverride:
Expand Down Expand Up @@ -774,6 +776,7 @@ PlayerSettings:
scriptingDefineSymbols:
Android: VUPLEX_STANDALONE
Standalone: VUPLEX_STANDALONE
iPhone:
additionalCompilerArguments:
Standalone:
- -nullable+
Expand Down Expand Up @@ -801,7 +804,7 @@ PlayerSettings:
allowUnsafeCode: 0
useDeterministicCompilation: 1
enableRoslynAnalyzers: 1
selectedPlatform: 2
selectedPlatform: 3
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
gcIncremental: 1
Expand Down

0 comments on commit b3472f8

Please sign in to comment.