Version: Unity 6 (6000.0)
LanguageEnglish
  • C#

PBXProject

class in UnityEditor.iOS.Xcode

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Represents an Xcode project (pbxproj file).

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

public class Sample_PBXProject { [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);

// Perform any modifications you want to the PBXProject

// Get the target GUID string mainTargetGuid = pbxProject.GetUnityMainTargetGuid();

// Add a new build configuration and add a new property to it string configName = "exampleConfig"; pbxProject.AddBuildConfig(configName); string configGuid = pbxProject.BuildConfigByName(mainTargetGuid, configName); pbxProject.AddBuildPropertyForConfig(configGuid, "exampleProperty", "exampleValue");

// Add a new file to project and to build list string filePath = Path.Combine(Application.dataPath, "Resources/InputFile.txt"); string fileGuid = pbxProject.AddFile(filePath, "Resources/InputFile.txt"); pbxProject.AddFileToBuild(mainTargetGuid, fileGuid);

// Add frameworks to the project pbxProject.AddFrameworkToProject(mainTargetGuid, "CoreBluetooth.framework", false); pbxProject.AddFrameworkToProject(mainTargetGuid, "MapKit.framework", true);

// Apply changes to the pbxproj file pbxProject.WriteToFile(projectPath); }

}

Properties

unityPostprocessTargetPhonyBuildPhaseNameThe name of the placeholder build phase, which Unity adds to indicate a place to add post-processing actions.

Constructors

PBXProjectCreates a new instance of PBXProject class.

Public Methods

AddAssetTagForFileAdds an asset tag for the given file.
AddAssetTagToDefaultInstallAdds the asset tag to the list of tags to download during initial installation.
AddBuildConfigCreates a new set of build configurations for all targets in the project.
AddBuildPropertyAdds a value to the build property list in all the build configurations for the specified target(s).
AddBuildPropertyForConfigAdds a value to build property list of the given build configuration(s).
AddCapabilityAdds a target capability to the Xcode project.
AddCopyFilesBuildPhaseCreates a new Copy Files build phase for a given target.
AddCopyFilesBuildPhaseBeforeTargetPostprocessCreates a new Copy Files build phase for a given target.
AddFileAdds a new file reference to the list of known files.
AddFileToBuildConfigure a file to build for the given native target.
AddFileToBuildSectionConfigures file for building for the given native target on specific build section.
AddFileToBuildWithFlagsConfigure a file for building for the given target with specific compiler flags.
AddFolderReferenceAdds a new folder reference to the list of known files.
AddFrameworksBuildPhaseCreates a new frameworks build phase for given target.
AddFrameworkToProjectAdds a system framework dependency for the specified target.
AddHeadersBuildPhaseCreates a new headers build phase for a given target.
AddKnownRegionAdds the provided regions to the Xcode Project.
AddLocaleVariantFileAdds Locale to Variant Group of Xcode Project for iOS platform.
AddPublicHeaderToBuildConfigures a file for building for the given native target as a public header.
AddRemotePackageFrameworkToProjectAdds a remote package framework dependency for the specified target.
AddRemotePackageReferenceAtBranchAdds a reference to the remote package at the given branch.
AddRemotePackageReferenceAtRevisionAdds a reference to the remote package at the given revision.
AddRemotePackageReferenceAtVersionAdds a reference to the remote package at the given version.
AddRemotePackageReferenceAtVersionUpToNextMajorAdds a reference to the remote package at the given version and allows updates up to the next major version.
AddRemotePackageReferenceAtVersionUpToNextMinorAdds a reference to the remote package at the given version and allows updates up to the next minor version.
AddRemotePackageReferenceWithVersionRangeAdds a reference to the remote package and allows updates in the given version range.
AddResourcesBuildPhaseCreates a new resources build phase for a given target.
AddShellScriptBuildPhaseCreates a new copy shell script phase for a given target.
AddShellScriptBuildPhaseBeforeTargetPostprocessCreates a new copy shell script phase for a given target.
AddSourcesBuildPhaseCreates a new sources build phase for a given target.
AddTargetCreates a new native target.
AddTargetDependencyCreates a dependency between this target and another target. The other target may be in a different project.
BuildConfigByNameReturns the GUID of build configuration with the given name for the specific target.
BuildConfigNamesReturns the names of the build configurations available in the project.
ClearKnownRegionsRemoves the deprecated regions that get added automatically in Xcode Project.
ContainsFileByProjectPathChecks if the project contains a file with the given project path.
ContainsFileByRealPathChecks if the project contains a file with the given physical path.
ContainsFrameworkChecks whether the given system framework is a dependency of a target.
FindFileGuidByProjectPathFinds a file with the given project path in the project.
FindFileGuidByRealPathFinds a file with the given physical path in the project.
GetAllBuildPhasesForTargetReturns all build phases for the specified target.
GetBaseReferenceForConfigGets the base configuration reference GUID for the specified build configuration.
GetBuildPhaseNameReturns the name of the build phase with the specified GUID.
GetBuildPhaseTypeReturns the type of the build phase with the specified GUID.
GetBuildPropertyForAnyConfigGets a build property value for the given name in all the build configurations for the specified target(s). If a property has multiple values, those are delimited by a space.
GetBuildPropertyForConfigGets a build property value for the given name in the specified build configuration(s). If a property has multiple values they are delimited by a space.
GetCompileFlagsForFileReturns compile flags set for the specific file on a given target.
GetCopyFilesBuildPhaseByTargetReturns the GUID of matching copy files build phase for the given target.
GetEntitlementFilePathForTargetReturns the relative path to the entitlement file for the specified build target.
GetFrameworksBuildPhaseByTargetReturns the GUID of frameworks build phase for the given target.
GetHeadersBuildPhaseByTargetReturns the GUID of the headers build phase for the given target.
GetRealPathsOfAllFilesReturn a list of all known files.
GetResourcesBuildPhaseByTargetReturns the GUID of resources build phase for the given target.
GetShellScriptBuildPhaseForTargetReturns the GUID of matching copy shell script build phase for the given target.
GetSourcesBuildPhaseByTargetReturns the GUID of sources build phase for the given target.
GetTargetProductFileRefReturns the file reference of the artifact created by building target.
GetUnityFrameworkTargetGuidReturns the GUID of the framework target in Unity project.
GetUnityMainTargetGuidReturns the GUID of the main target in Unity project.
InsertCopyFilesBuildPhaseCreates a new copy files build phase for a given target.
InsertShellScriptBuildPhaseCreates a new shell script build phase for a given target.
ProjectGuidReturns the GUID of the project.
ReadFromFileReads the project from a file identified by the given path.
ReadFromStreamReads the project from the given text reader.
ReadFromStringReads the project from the given string.
RemoveAssetTagRemoves an asset tag.
RemoveAssetTagForFileRemoves an asset tag for the given file.
RemoveAssetTagFromDefaultInstallRemoves the asset tag from the list of tags to download during initial installation.
RemoveBuildConfigRemoves all build configurations with the given name from all targets in the project.
RemoveFileRemoves the given file from project.
RemoveFileFromBuildRemoves the given file from the list of files to build for the given target.
RemoveFrameworkFromProjectRemoves a system framework dependency for the specified target.
ReplaceFileReplaces a specified file with a new file.
SetBaseReferenceForConfigSets the base configuration reference for the specified build configuration.
SetBuildPropertySets a build property to the given value in all build configurations for the specified target(s).
SetBuildPropertyForConfigSets a build property to the given value in the specified build configuration(s).
SetCompileFlagsForFileSets the compilation flags for the given file in the given target.
SetDevelopmentRegionSets the default language and region for the bundle in Xcode Project.
SetTeamIdSets the Team ID of an Xcode project.
TargetGuidByNameReturns the GUID of the native target with the given name.
UpdateBuildPropertyAdds and removes values from a build property in all build configurations for the specified target(s).
UpdateBuildPropertyForConfigAdds and removes values from a build property in the given build configuration.
WriteToFileWrites the project contents to the specified file.
WriteToStreamWrites the project contents to the specified text writer.
WriteToStringWrites the contents of the project to string.

Static Methods

GetPBXProjectPathReturns the path to PBX project in the given Unity build path.
GetUnityTestTargetNameReturns the default test target name.
IsBuildableChecks if a file with the given extension can be built by Xcode.
IsKnownExtensionChecks if files with the given extension are known to PBXProject.