Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity command line arguments for android and iOS

Please pardon my ignorance, relatively new to working with Unity3D. I am working on automating Unity3d builds from the command line.

I am looking for command line arguments to build apk & xcode project. Unity's documentation does mention arguments to build a standalone Mac OSX player (-buildOSXPlayer) and a standalone Windows player (-buildWindowsPlayer) but not for android and iOS.

Any help would be really appreciated. Thanks.

like image 824
Arun Nair Avatar asked Feb 14 '23 16:02

Arun Nair


1 Answers

Start with Unity's own documentation for command line builds for iOS and android.

For example, put this script in your Assets/Editor folder:

// C# example
using UnityEditor;
class Autobuilder
{
     [MenuItem ("File/AutoBuilder/iOS")]
     static void PerformBuild ()
     {
         string[] scenes = { "Assets/MyScene.unity" };

         string buildPath = "../../../Build/iOS";

         // Create build folder if not yet exists
         Directory.CreateDirectory(buildPath);

         BuildPipeline.BuildPlayer(scenes, buildPath, BuildTarget.iOS, BuildOptions.Development);
     }
}

You can actually run this script in the Unity application by going to File -> Autobuilder -> iOS

To run on command line, it looks something like this:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod Autobuilder.PerformBuild -email [email protected] -password myPassword

Of course, you're going to want to check the debug log for any errors:

Mac OS X ~/Library/Logs/Unity/Editor.log
Windows XP C:\Documents and Settings\username\Local Settings\Application Data_\Unity\Editor\Editor.log
Windows Vista/7 C:\Users\username\AppData\Local\Unity\Editor\Editor.log

like image 59
Jon Avatar answered Feb 25 '23 01:02

Jon