Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetBuildPropertyForConfig

Sets a build property to the given value in the specified build configuration(s).
Read time 2 minutesLast updated 10 days ago

Definition

SetBuildPropertyForConfig(string, string, string)

Sets a build property to the given value in the specified build configuration(s).
public void SetBuildPropertyForConfig(string configGuid, string name, string value)

Parameters

configGuid

The GUID of the build configuration as returned by PBXProject.BuildConfigByName.

name

The name of the build property.

value

The value of the build property.

Remarks

Duplicate build properties are ignored. Values for names
LIBRARY_SEARCH_PATHS
and
FRAMEWORK_SEARCH_PATHS
are quoted if they contain spaces.

Examples

using UnityEditor;using System.IO;using UnityEditor.Callbacks;using UnityEditor.iOS.Xcode;public class Sample_SetBuildPropertyForConfig { [PostProcessBuild] public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject) { // Stop processing if build target is not iOS if (buildTarget != BuildTarget.iOS) return; // Initialize PBXProject string projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject); PBXProject pbxProject = new PBXProject(); pbxProject.ReadFromFile(projectPath); // Get the GUID you want to set a build property on string unityFrameworkTargetGuid = pbxProject.GetUnityFrameworkTargetGuid(); // Get the GUID of the "Debug" config so you can use it to change config-specific settings string configGuid = pbxProject.BuildConfigByName(unityFrameworkTargetGuid, "Debug"); // Set "ENABLE_BITCODE" to "NO" for "Debug" config pbxProject.SetBuildPropertyForConfig(configGuid, "ENABLE_BITCODE", "NO"); // Apply changes to the pbxproj file pbxProject.WriteToFile(projectPath); }}

SetBuildPropertyForConfig(IEnumerable<string>, string, string)

Sets a build property to the given value in the specified build configuration(s).
public void SetBuildPropertyForConfig(IEnumerable<string> configGuids, string name, string value)

Parameters

The GUIDs of the build configurations as returned by PBXProject.BuildConfigByName.

name

The name of the build property.

value

The value of the build property.

Remarks

Duplicate build properties are ignored. Values for names
LIBRARY_SEARCH_PATHS
and
FRAMEWORK_SEARCH_PATHS
are quoted if they contain spaces.

Examples

using UnityEditor;using System.IO;using UnityEditor.Callbacks;using UnityEditor.iOS.Xcode;public class Sample_SetBuildPropertyForConfig { [PostProcessBuild] public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject) { // Stop processing if build target is not iOS if (buildTarget != BuildTarget.iOS) return; // Initialize PBXProject string projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject); PBXProject pbxProject = new PBXProject(); pbxProject.ReadFromFile(projectPath); // Get the GUID you want to set a build property on string unityFrameworkTargetGuid = pbxProject.GetUnityFrameworkTargetGuid(); // Get the GUID of the "Debug" config so you can use it to change config-specific settings string configGuid = pbxProject.BuildConfigByName(unityFrameworkTargetGuid, "Debug"); // Set "ENABLE_BITCODE" to "NO" for "Debug" config pbxProject.SetBuildPropertyForConfig(configGuid, "ENABLE_BITCODE", "NO"); // Apply changes to the pbxproj file pbxProject.WriteToFile(projectPath); }}