[转]Xcode Project File Format

Introduction

The Xcode project file is an old-style plist (Next style) based on braces to delimit the hierarchy. The file begins with an explicit encoding information, usually the UTF-8 one. This means that the file must not bear a BOM (Byte Ordering Mark) at its start or the parsing will fail.

Note: The following document is based on observations of various *.pbxproj files and element properties have been inferred. There was not code reverse engineering involved what so ever.

Unique Identification

Each element in the file is uniquely identified by a 96 bits identifier using a 24 hexadecimal representation. This unique identifier is unique accross the document.

The algorithm used by Xcode to generate the unique identifier seems to be based both on date, sequence and pre-defined values, but as there is no evidence that these identifiers must follow a generation convention, one can think that arbitrary identifier can be used, as long as they are unique accross the document.

The following references were useful while writing this note:

Elements

Here is the list of elements contained in the file format:

Root Element

The root section contains the general informations.

AttributeTypeValueComment
archiveVersionNumber1Default value.
classesListEmpty
objectVersionNumberSee XcodeCompatibilityVersion enumeration.
objectsMapA map of elementThe map is indexed by the elements identifier.
rootObjectReferenceAn element referenceThe object is a reference to a PBXProject element.

Example:

// !$*UTF8*$!
{
    archiveVersion
= 1;
    classes
= {
   
};
    objectVersion
= 45;
    objects
= {

   
...

   
};
    rootObject
= 0867D690FE84028FC02AAC07 /* Project object */;
}

PBXAggregateTarget

This is the element for a build target that aggregates several others.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXAggregateTargetEmpty
buildConfigurationListReferenceAn element referenceThe object is a reference to a XCConfigurationList element.
buildPhasesListA list of element referenceThe objects are a reference to a PBXBuildPhase element.
dependenciesListA list of element referenceThe objects are a reference to a PBXTargetDependency element.
nameStringThe name of the target.
productNameStringThe product name.

Example:

4DA521A6115A00AF007C19C3 /* documentation */ = {
    isa
= PBXAggregateTarget;
    buildConfigurationList
= 4DA521AE115A00ED007C19C3 /* Build configuration list for PBXAggregateTarget "documentation" */;
    buildPhases
= (
       
4DA521A5115A00AF007C19C3 /* ShellScript */,
   
);
    dependencies
= (
       
4DA521AA115A00BC007C19C3 /* PBXTargetDependency */,
   
);
    name
= documentation;
    productName
= documentation;
};

PBXBuildFile

This element indicate a file reference that is used in a PBXBuildPhase (either as an include or resource).

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXBuildFileEmpty
fileRefReferenceAn element referenceThe object is a reference to a PBXFileReference element.
settingsMapA map of key/value pairs for additionnal settings.

Example:

4D05CA6B1193055000125045 /* xxx.c in Sources */ = {
    isa
= PBXBuildFile;
    fileRef
= 4D05CA411193055000125045 /* xxx.c */;
};

PBXBuildPhase

This element is an abstract parent for specialized build phases.

PBXContainerItemProxy

This is the element for to decorate a target item.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXContainerItemProxyEmpty
containerPortalReferenceAn element referenceThe object is a reference to a PBXProject element.
proxyTypeNumber1
remoteGlobalIDStringReferenceAn element referenceA unique reference ID.
remoteInfoString

Example:

4D22DC0C1167C992007AF714 /* PBXContainerItemProxy */ = {
    isa
= PBXContainerItemProxy;
    containerPortal
= 08FB7793FE84155DC02AAC07 /* Project object */;
    proxyType
= 1;
    remoteGlobalIDString
= 87293EBF1153C114007AFD45;
    remoteInfo
= xxx;
};

PBXCopyFilesBuildPhase

This is the element for the copy file build phase.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXCopyFilesBuildPhaseEmpty
buildActionMaskNumber2^32-1
dstPathStringThe destination path
dstSubfolderSpecNumber
filesListA list of element referenceThe objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessingNumber0

Example:

MISSING

PBXFileElement

This element is an abstract parent for file and group elements.

PBXFileReference

A PBXFileReference is used to track every external file referenced by the project: source files, resource files, libraries, generated application files, and so on.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXFileReferenceEmpty
fileEncodingNumberSee the PBXFileEncoding enumeration.
explicitFileTypeStringSee the PBXFileType enumeration.
lastKnownFileTypeStringSee the PBXFileType enumeration.
nameStringThe filename.
pathStringThe path to the filename.
sourceTreeStringSee the PBXSourceTree enumeration.

Example:

87293F901153D870007AFD45 /* monobjc.mm */ = {
    isa
= PBXFileReference;
    fileEncoding
= 4;
    lastKnownFileType
= sourcecode.cpp.objcpp;
    name
= monobjc.mm;
    path
= sources/monobjc.mm;
    sourceTree
= "";
};

PBXFrameworksBuildPhase

This is the element for the framewrok link build phase.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXFrameworksBuildPhaseEmpty
buildActionMaskNumber2^32-1
filesListA list of element referenceThe objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessingNumber0

Example:

4D05CA2C119304BD00125045 /* Frameworks */ = {
    isa
= PBXFrameworksBuildPhase;
    buildActionMask
= 2147483647;
    files
= (
   
);
    runOnlyForDeploymentPostprocessing
= 0;
};

PBXGroup

This is the element to group files or groups.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXGroupEmpty
childrenListA list of element referenceThe objects are a reference to a PBXFileElement element.
nameStringThe filename.
sourceTreeStringSee the PBXSourceTree enumeration.

Example:

4DA521A2115A003E007C19C3 /* scripts */ = {
    isa
= PBXGroup;
    children
= (
   
4D22DBAF116742DE007AF714 /* fix_references.sh */,
   
4DA521A1115A0032007C19C3 /* generate_descriptors.sh */,
   
);
    name
= scripts;
    sourceTree
= "";
};

PBXHeadersBuildPhase

This is the element for the framewrok link build phase.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXHeadersBuildPhaseEmpty
buildActionMaskNumber2^32-1
filesListA list of element referenceThe objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessingNumber0

Example:

87293EBC1153C114007AFD45 /* Headers */ = {
    isa
= PBXHeadersBuildPhase;
    buildActionMask
= 2147483647;
    files
= (
   
);
    runOnlyForDeploymentPostprocessing
= 0;
};

PBXLegacyTarget

PBXNativeTarget

This is the element for a build target that produces a binary content (application or library).

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXNativeTargetEmpty
buildConfigurationListReferenceAn element referenceThe object is a reference to a XCConfigurationList element.
buildPhasesListA list of element referenceThe objects are a reference to a PBXBuildPhase element.
dependenciesListA list of element referenceThe objects are a reference to a PBXTargetDependency element.
nameStringThe name of the target.
productInstallPathStringThe product install path.
productNameStringThe product name.
productReferenceReferenceAn element referenceThe object is a reference to a PBXFileReference element.
productTypeStringSee the PBXProductType enumeration.

Example:

8D1107260486CEB800E47090 /* XXX */ = {
    isa
= PBXNativeTarget;
    buildConfigurationList
= C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "XXX" */;
    buildPhases
= (
       
8D1107290486CEB800E47090 /* Resources */,
       
8D11072C0486CEB800E47090 /* Sources */,
       
8D11072E0486CEB800E47090 /* Frameworks */,
   
);
    buildRules
= (
   
);
    dependencies
= (
   
);
    name
= XXX;
    productInstallPath
= "$(HOME)/Applications";
    productName
= TrackIt;
    productReference
= 8D1107320486CEB800E47090 /* XXX.app */;
    productType
= "com.apple.product-type.application";
};

PBXProject

This is the element for a build target that produces a binary content (application or library).

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXProjectEmpty
buildConfigurationListReferenceAn element referenceThe object is a reference to a XCConfigurationList element.
compatibilityVersionStringA string representation of the XcodeCompatibilityVersion.
developmentRegionStringThe region of development.
hasScannedForEncodingsNumberWhether file encodings have been scanned.
knownRegionsListA list of stringThe known regions for localized files.
mainGroupReferenceAn element referenceThe object is a reference to a PBXGroup element.
productRefGroupReferenceAn element referenceThe object is a reference to a PBXGroup element.
projectDirPathStringThe relative path of the project.
projectReferencesArray of mapEach map in the array contains two keys: ProductGroup and ProjectRef.
projectRootStringThe relative root path of the project.
targetsListA list of element referenceThe objects are a reference to a PBXTarget element.

Example:

29B97313FDCFA39411CA2CEA /* Project object */ = {
        isa
= PBXProject;
        buildConfigurationList
= C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XXX" */;
        compatibilityVersion
= "Xcode 2.4";
        developmentRegion
= English;
        hasScannedForEncodings
= 1;
        knownRegions
= (
               
English,
               
Japanese,
               
French,
               
German,
                en
,
       
);
        mainGroup
= 29B97314FDCFA39411CA2CEA /* XXX*/;
        projectDirPath
= "";
        projectRoot
= "";
        targets
= (
             
8D1107260486CEB800E47090 /* XXX*/,
       
);
};

PBXResourcesBuildPhase

This is the element for the resources copy build phase.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXResourcesBuildPhaseEmpty
buildActionMaskNumber2^32-1
filesListA list of element referenceThe objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessingNumber0

Example:

8D1107290486CEB800E47090 /* Resources */ = {
        isa
= PBXResourcesBuildPhase;
        buildActionMask
= 2147483647;
        files
= (
               
535C1E1B10AB6B6300F50231 /* ReadMe.txt in Resources */,
               
533B968312721D05005E617D /* Credits.rtf in Resources */,
               
533B968412721D05005E617D /* InfoPlist.strings in Resources */,
               
533B968512721D05005E617D /* MainMenu.nib in Resources */,
               
533B968612721D05005E617D /* TableEdit.nib in Resources */,
               
533B968712721D05005E617D /* TestWindow.nib in Resources */,
       
);
        runOnlyForDeploymentPostprocessing
= 0;
};

PBXShellScriptBuildPhase

This is the element for the resources copy build phase.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXShellScriptBuildPhaseEmpty
buildActionMaskNumber2^32-1
filesListA list of element referenceThe objects are a reference to a PBXBuildFile element.
inputPathsListA list of stringThe input paths.
outputPathsListA list of stringThe output paths.
runOnlyForDeploymentPostprocessingNumber0
shellPathStringThe path to the shell interpreter.
shellScriptStringThe content of the script shell.

Example:

4D22DBAE11674009007AF714 /* ShellScript */ = {
        isa
= PBXShellScriptBuildPhase;
        buildActionMask
= 2147483647;
        files
= (
       
);
        inputPaths
= (
       
);
        outputPaths
= (
       
);
        runOnlyForDeploymentPostprocessing
= 0;
        shellPath
= /bin/sh;
        shellScript
= "./fix_references.sh";
};

PBXSourcesBuildPhase

This is the element for the sources compilation build phase.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXSourcesBuildPhaseEmpty
buildActionMaskNumber2^32-1
filesListA list of element referenceThe objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessingNumber0

Example:

4DF8B22D1171CFBF0081C1DD /* Sources */ = {
        isa
= PBXSourcesBuildPhase;
        buildActionMask
= 2147483647;
        files
= (
               
4DF8B23E1171D0310081C1DD /* test.mm in Sources */,
       
);
        runOnlyForDeploymentPostprocessing
= 0;
};

PBXTarget

This element is an abstract parent for specialized targets.

PBXTargetDependency

This is the element for referencing other target through content proxies.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXTargetDependencyEmpty
targetReferenceAn element referenceThe object is a reference to a PBXNativeTarget element.
targetProxyReferenceAn element referenceThe object is a reference to a PBXContainerItemProxy element.

Example:

4D22DC0D1167C992007AF714 /* PBXTargetDependency */ = {
        isa
= PBXTargetDependency;
        target
= 87293EBF1153C114007AFD45 /* libXXX */;
        targetProxy
= 4D22DC0C1167C992007AF714 /* PBXContainerItemProxy */;
};

PBXVariantGroup

This is the element for referencing localized resources.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaPBXVariantGroupEmpty
childrenListA list of element referenceThe objects are a reference to a PBXFileElement element.
nameStringThe filename.
sourceTreeStringSee the PBXSourceTree enumeration.

Example:

870C88031338A77600A69309 /* MainMenu.xib */ = {
        isa
= PBXVariantGroup;
        children
= (
               
870C88041338A77600A69309 /* en */,
       
);
        name
= MainMenu.xib;
        sourceTree
= "";
};

XCBuildConfiguration

This is the element for defining build configuration.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier
isaXCBuildConfigurationEmpty
baseConfigurationReferenceStringThe path to a xcconfig file
buildSettingsMapA map of build settings.
nameStringThe configuration name.

Example:

870C88151338ABB600A69309 /* Debug */ = {
        isa
= XCBuildConfiguration;
        buildSettings
= {
                PRODUCT_NAME
= "$(TARGET_NAME)";
       
};
        name
= Debug;
};
870C88161338ABB600A69309 /* Release */ = {
        isa
= XCBuildConfiguration;
        buildSettings
= {
                PRODUCT_NAME
= "$(TARGET_NAME)";
       
};
        name
= Release;
};

XCConfigurationList

This is the element for listing build configurations.

AttributeTypeValueComment
referenceUUIDA 96 bits identifier 
isaXCConfigurationListEmpty 
buildConfigurationsListA list of element referenceThe objects are a reference to a XCBuildConfiguration element.
defaultConfigurationIsVisibleNumber0 
defaultConfigurationNameString The default configuration name.

Example:

870C87E41338A77600A69309 /* Build configuration list for PBXProject "CocoaApp" */ = {
        isa
= XCConfigurationList;
        buildConfigurations
= (
               
870C88061338A77600A69309 /* Debug */,
               
870C88071338A77600A69309 /* Release */,
       
);
        defaultConfigurationIsVisible
= 0;
        defaultConfigurationName
= Release;
};

原文地址:https://www.cnblogs.com/Proteas/p/2747582.html