SetBuildPropertyForConfig
Sets a build property to the given value in the specified build configuration(s).
Read time 2 minutesLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEditor.iOS.Xcode
- Assembly: UnityEditor.iOS.Extensions.Xcode
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
The GUID of the build configuration as returned by PBXProject.BuildConfigByName.
The name of the build property.
The value of the build property.
Remarks
Duplicate build properties are ignored. Values for names and are quoted if they contain spaces.
LIBRARY_SEARCH_PATHSFRAMEWORK_SEARCH_PATHSExamples
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.
The name of the build property.
The value of the build property.
Remarks
Duplicate build properties are ignored. Values for names and are quoted if they contain spaces.
LIBRARY_SEARCH_PATHSFRAMEWORK_SEARCH_PATHSExamples
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); }}