2

I'm building for iOS and using the FacebookSDK. And I want to automate thru Jenkins. Now when I "build and Run" in the editor, It builds the xcode project correctly. But when I run it thru the commandline the postbuildprocess never gets run. I can't find anything online about this issues. Anyone have any ideas? Or need any other info to come up with a theory?

Here is the autobuild code:

[MenuItem("Build/iOS")]
static void PerformiOSBuild ()
{
    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iPhone);
    BuildPipeline.BuildPlayer(GetScenePaths(), "iOS",BuildTarget.iPhone,BuildOptions.None);
}

and here is my commandline args:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -projectPath "/Users/USERNAME/Desktop/Work/PROJECTNAME/Unity/"  -executeMethod AutoBuilder.PerformiOSBuild -quit -batchmode
1
  • Try removing "SwitchActiveBuildTarget". You should only ever do that once (the first time you setup the Jenkins Project). We actually stop the build and restart it after it switches build targets the first time. Commented Dec 13, 2013 at 23:37

2 Answers 2

1

I was able to get around this by calling Facebook's PostProcess manually. Here's my build script:

using System;
using UnityEngine;
using UnityEditor;
using UnityEditor.FacebookEditor;

class BuildScript
{
    static void PerformBuild ()
    {
        string[] scenes = { "Assets/monster_island.unity" };
        string buildPath = System.IO.Directory.GetCurrentDirectory() + "/iOS";
        BuildOptions opt = BuildOptions.None;
        BuildTarget target = BuildTarget.iPhone;

        // Run Xcode project build
        BuildPipeline.BuildPlayer(scenes, buildPath, target, opt);

        // Run Facebook's post-processing script
        XCodePostProcess.OnPostProcessBuild(target, buildPath);
    }
}

Keep in mind I'm new to Unity, so if something in here looks gross feel free to say so.

Sign up to request clarification or add additional context in comments.

Comments

1

just found this and the same question at Unity forums, so I'll paste here the same answer that I gave there, one could check through this link.

Hello, sorry to revive this old post but in 2019 it still is one of the top links in Google.

Just had the same problem and what @Brentonb said is still valid, today it is documented in this link for SwitchActiveBuildTarget and it states:

Note: This method is not available when running the Editor in batch mode. This is because changing the build target requires recompiling script code for the given target which cannot be done while script code is executing (not a problem in in the editor as the operation is simply deferred but batch mode will immediately exit after having executed the designated script code). To set the build target to use in batch mode, use the buildTarget command-line switch.

Then I checked here, in the Command line arguments page in the manual, and added -buildTarget Android and -buildTarget iOS for each of the methods of the CI build process.

Now my PostBuild script for iOS executes in batch mode as well.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.