I am doing the iOS builds for a group of Unity (Unity3d) game developers.

After pulling the latest git updates, I start up the Unity editor on my Mac and choose "Build Settings", select the iOS target platform, press Build, specify a destination folder and that is it.

Can this exact process be done automatically via the terminal prompt?


Android and iOS are not directly supported by the command line utility. However, you can use the command line utility to run a script that will build for iOS. In the simplest form, it would be something like:

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;

public static class AutoBuilder {

    static string GetProjectName()
        string[] s = Application.dataPath.Split('/');
        return s[s.Length - 2];

    static string[] GetScenePaths()
        string[] scenes = new string[EditorBuildSettings.scenes.Length];

        for(int i = 0; i < scenes.Length; i++)
            scenes[i] = EditorBuildSettings.scenes[i].path;

        return scenes;
    static void PerformiOSBuild ()
        BuildPipeline.BuildPlayer(GetScenePaths(), "Builds/iOS",BuildTarget.iPhone,BuildOptions.None);

Then, you would call this from the command line with

-executeMethod AutoBuilder.PerformiOSBuild
  • \$\begingroup\$ How do you change the build target? \$\endgroup\$ – Ali Jan 19 '18 at 14:35
  • 1
    \$\begingroup\$ @Ali Check out the BuildTarget enum in the BuildPlayer and SwitchActiveBuildTarget methods. \$\endgroup\$ – MichaelHouse Jan 20 '18 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.