Xcode Project File Format

本文介绍了Xcode项目文件的格式特点及元素构成,包括文件的基本结构、标识符生成规则及各种构建目标、文件引用等元素的属性说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[http://www.monobjc.net/xcode-project-file-format.html]

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:

A brief look at the Xcode project format [Cmake] Re: CMake Apple XCode support? PBTOMAKE -- Xcode to Unix

Elements

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

  • Root Element
  • PBXBuildFile
  • PBXBuildPhase
    • PBXAppleScriptBuildPhase
    • PBXCopyFilesBuildPhase
    • PBXFrameworksBuildPhase
    • PBXHeadersBuildPhase
    • PBXResourcesBuildPhase
    • PBXShellScriptBuildPhase
    • PBXSourcesBuildPhase
  • PBXContainerItemProxy
  • PBXFileElement
    • PBXFileReference
    • PBXGroup
    • PBXVariantGroup
  • PBXTarget
    • PBXAggregateTarget
    • PBXLegacyTarget
    • PBXNativeTarget
  • PBXProject
  • PBXTargetDependency
  • XCBuildConfiguration
  • XCConfigurationList

Root Element

The root section contains the general informations.

Attribute Type Value Comment
archiveVersion Number 1 Default value.
classes List Empty  
objectVersion Number   See XcodeCompatibilityVersion enumeration.
objects Map A map of element The map is indexed by the elements identifier.
rootObject Reference An element reference The 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXAggregateTarget Empty  
buildConfigurationList Reference An element reference The object is a reference to a XCConfigurationList element.
buildPhases List A list of element reference The objects are a reference to a PBXBuildPhase element.
dependencies List A list of element reference The objects are a reference to a PBXTargetDependency element.
name String The name of the target.  
productName String The 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).

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXBuildFile Empty  
fileRef Reference An element reference The object is a reference to a PBXFileReference element.
settings Map   A 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXContainerItemProxy Empty  
containerPortal Reference An element reference The object is a reference to a PBXProject element.
proxyType Number 1  
remoteGlobalIDString Reference An element reference A unique reference ID.
remoteInfo String    

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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXCopyFilesBuildPhase Empty  
buildActionMask Number 2^32-1  
dstPath String The destination path  
dstSubfolderSpec Number    
files List A list of element reference The objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessing Number 0  

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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXFileReference Empty  
fileEncoding Number   See the PBXFileEncoding enumeration.
explicitFileType String   See the PBXFileType enumeration.
lastKnownFileType String   See the PBXFileType enumeration.
name String The filename.  
path String The path to the filename.  
sourceTree String See 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXFrameworksBuildPhase Empty  
buildActionMask Number 2^32-1  
files List A list of element reference The objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessing Number 0  

Example:

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

PBXGroup

This is the element to group files or groups.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXGroup Empty  
children List A list of element reference The objects are a reference to a PBXFileElement element.
name String The filename.  
sourceTree String See 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXHeadersBuildPhase Empty  
buildActionMask Number 2^32-1  
files List A list of element reference The objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessing Number 0  

Example:

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

PBXLegacyTarget

MISSING

PBXNativeTarget

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

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXNativeTarget Empty  
buildConfigurationList Reference An element reference The object is a reference to a XCConfigurationList element.
buildPhases List A list of element reference The objects are a reference to a PBXBuildPhase element.
dependencies List A list of element reference The objects are a reference to a PBXTargetDependency element.
name String The name of the target.  
productInstallPath String The product install path.  
productName String The product name.  
productReference Reference An element reference The object is a reference to a PBXFileReference element.
productType String   See 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).

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXProject Empty  
buildConfigurationList Reference An element reference The object is a reference to a XCConfigurationList element.
compatibilityVersion String A string representation of the XcodeCompatibilityVersion.  
developmentRegion String   The region of development.
hasScannedForEncodings Number 0 or 1 Whether file encodings have been scanned.
knownRegions List A list of string The known regions for localized files.
mainGroup Reference An element reference The object is a reference to a PBXGroup element.
productRefGroup Reference An element reference The object is a reference to a PBXGroup element.
projectDirPath String The relative path of the project.  
projectReferences Array of map Each map in the array contains two keys: ProductGroup and ProjectRef.  
projectRoot String The relative root path of the project.  
targets List A list of element reference The 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXResourcesBuildPhase Empty  
buildActionMask Number 2^32-1  
files List A list of element reference The objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessing Number 0  

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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXShellScriptBuildPhase Empty  
buildActionMask Number 2^32-1  
files List A list of element reference The objects are a reference to a PBXBuildFile element.
inputPaths List A list of string The input paths.
outputPaths List A list of string The output paths.
runOnlyForDeploymentPostprocessing Number 0  
shellPath String The path to the shell interpreter.  
shellScript String The 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXSourcesBuildPhase Empty  
buildActionMask Number 2^32-1  
files List A list of element reference The objects are a reference to a PBXBuildFile element.
runOnlyForDeploymentPostprocessing Number 0  

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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXTargetDependency Empty  
target Reference An element reference The object is a reference to a PBXNativeTarget element.
targetProxy Reference An element reference The 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa PBXVariantGroup Empty  
children List A list of element reference The objects are a reference to a PBXFileElement element.
name String The filename.  
sourceTree String See 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa XCBuildConfiguration Empty  
baseConfigurationReference String The path to a xcconfig file  
buildSettings Map A map of build settings.  
name String The 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.

Attribute Type Value Comment
reference UUID A 96 bits identifier  
isa XCConfigurationList Empty  
buildConfigurations List A list of element reference The objects are a reference to a XCBuildConfiguration element.
defaultConfigurationIsVisible Number 0  
defaultConfigurationName String The default configuration name.  

Example:

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

### 安装和配置 Qv2ray #### 下载并准备 Qv2ray 应用程序图像文件 为了在 Ubuntu 上安装 Qv2ray,首先需要获取应用程序的 AppImage 文件。可以从官方网站或其他可信资源下载最新版本。 ```bash wget https://github.com/Qv2ray/Qv2ray/releases/download/v2.7.0/Qv2ray-v2.7.0-linux-x64.AppImage ``` #### 设置可执行权限 下载完成后,需设置该文件具有可执行权限以便启动它[^3]: ```bash sudo chmod +x ./Qv2ray-v2.7.0-linux-x64.AppImage ``` #### 创建桌面快捷方式(可选) 如果希望创建一个桌面图标来方便访问 Qv2ray,则可以按照下面的方法操作[^2]: 1. 编辑一个新的 `.desktop` 文件用于定义应用程序条目: ```bash cd /usr/share/applications && sudo gedit Qv2ray.desktop ``` 2. 将下列内容粘贴进去,并根据实际情况调整路径: ```ini [Desktop Entry] Encoding=UTF-8 Name=Qv2ray Comment=A GUI client for V2Ray based on Qt5. Exec=/path/to/your/Qv2ray-v2.7.0-linux-x64.AppImage Icon=/path/to/icon/Qv2ray.png Terminal=false StartupNotify=true Type=Application Categories=Network; ``` 3. 授予 `.desktop` 文件必要的权限使其成为有效的启动器: ```bash sudo chmod u+x Qv2ray.desktop ``` #### 解决可能遇到的问题 当更改用户组之后发现 Qv2ray 无法正常工作时,可能是由于缺少某些特定的能力(capabilities),可以通过给定二进制文件增加这些能力来修复这个问题[^4]: ```bash sudo setcap cap_net_bind_service=+ep cap_net_admin=+ep /path/to/qv2ray_executable_file ``` #### 配置全局代理(适用于命令行工具) 对于那些依赖于 HTTP 或 SOCKS5 协议的应用和服务来说,在设置了 Qv2ray 的监听端口后还需要进一步修改环境变量以实现全局代理功能[^5]。这通常涉及到编辑用户的 shell profile 文件如 `~/.bashrc` 添加如下几行代码: ```bash export http_proxy="http://127.0.0.1:8889" export https_proxy=$http_proxy export all_proxy="socks5://127.0.0.1:1089" ``` 完成上述步骤后记得使新的环境变量生效: ```bash source ~/.bashrc ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值