0

I want to change 'Run script only when installing' flag from false to true when every time I build xCode project from Unity Editor. Expected result should be like in screenshot. enter image description here

Here is my code that adds shell script to build phase when I build xCode project. It should run only after Archive process to delete some files from archived file. Unity documentation related to my script -> https://docs.unity3d.com/2020.2/Documentation/ScriptReference/iOS.Xcode.PBXProject.html

using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;

namespace VP.Nest.System.Editor
{
    public static class DeleteFrameworkIOS
    {
        [PostProcessBuild(1000)]
        public static void OnPostProcessBuild(BuildTarget target, string pathToBuildProject)
        {
            if (target == BuildTarget.iOS)
            {
                var projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);

                var pbxProject = new PBXProject();
                pbxProject.ReadFromFile(projectPath);

#if UNITY_2019_3_OR_NEWER
                var targetGuid = pbxProject.GetUnityMainTargetGuid();
#else
            var targetName = PBXProject.GetUnityTargetName();
            var targetGuid = pbxProject.TargetGuidByName(targetName);
#endif
                string shellScriptPath = Path.GetDirectoryName(Application.dataPath) + "/Assets/VirtualProjects/Games/Scripts/Editor/BuildAutomation/DeleteFrameworkXCode.sh";

                pbxProject.AddShellScriptBuildPhase(targetGuid,"Run Script DeleteFrameworkXCode.sh", "/bin/sh", shellScriptPath);
                //TODO: Set 'Run script only when installing' flag to true
                pbxProject.WriteToFile(projectPath);
            }
        }
    }
}

How can I set this "For Install builds only" flag to true from my script? I should be able to do something like this -> https://gist.github.com/rizumita/4240658a9c999460ec4777ba5825f791

1 Answer 1

0

I meet the same question and I resolve it by inserting codes in podfile like this:

phase = target.shell_script_build_phases.find { |bp| ignoringScriptNames.include?(your_phase_name) }
phase.run_only_for_deployment_postprocessing = "1"

This may help you.

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

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.