project.pbxproj は NeXTSTEP の Old-style ASCII Property List(OpenStep plist)形式で記述されたテキストファイルである。Xcode プロジェクトのビルドターゲット、ファイル参照、ビルド設定などすべての構成情報を保持する。
以下の文字のみで構成される文字列はクォートなしで記述できる:
A-Z a-z 0-9 _ . $ / \ [ ] + - * @ ! < > | & ^ ~ % # ` ? '
例:
isa = PBXBuildFile;
path = Sources/Models/User.swift;
productType = com.apple.product-type.framework;
スペースや上記以外の文字を含む場合は二重引用符で囲む:
name = "Supporting Files";
compatibilityVersion = "Xcode 14.0";
sourceTree = "<group>";
shellScript = "echo \"Hello World\"\n";
クォート文字列内で使用できるエスケープ:
| シーケンス | 意味 |
|---|---|
\" |
二重引用符 |
\\ |
バックスラッシュ |
\n |
改行 |
\t |
タブ |
\r |
キャリッジリターン |
\0 |
ヌル文字 |
空文字列は "" と記述する:
projectDirPath = "";
projectRoot = "";
2つの用途がある:
UUID アノテーション — UUID の直後にファイル名やオブジェクト名を付記する:
3106FB60... /* ProtectedTests.swift */
A8491E1D... /* SwiftyJSON.swift in Sources */
2E4FEFDB... /* Build configuration list for PBXProject "MyApp" */
セクション区切り — objects 辞書内で ISA ごとのブロックを区切る:
/* Begin PBXBuildFile section */
...
/* End PBXBuildFile section */
ファイル先頭のマジックコメントにのみ使用される:
// !$*UTF8*$!
name = Debug;
path = "path with spaces";
丸括弧で囲み、要素はカンマ区切り。末尾要素の後にもカンマを付ける:
files = (
3106FB61... /* file.swift in Sources */,
A8491E1D... /* other.swift in Sources */,
);
空配列:
dependencies = (
);
波括弧で囲み、エントリは key = value; 形式。各エントリはセミコロンで終端する:
buildSettings = {
SWIFT_VERSION = 5.0;
PRODUCT_BUNDLE_IDENTIFIER = "org.example.App";
};
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objects = {
...
};
rootObject = <UUID> /* Project object */;
}
| キー | 値 | 説明 |
|---|---|---|
archiveVersion |
1 |
常に 1 |
classes |
{} |
常に空辞書 |
objectVersion |
数値 | フォーマットバージョン(後述) |
objects |
辞書 | 全オブジェクトを UUID キーで格納 |
rootObject |
UUID | PBXProject オブジェクトの UUID |
インデントにはタブ文字(\t)を使用する。
| objectVersion | compatibilityVersion | 対応 Xcode |
|---|---|---|
| 46 | Xcode 3.2 | — |
| 47 | Xcode 6.3 | Xcode 6.3 |
| 52 | Xcode 3.2 | — |
| 53 | Xcode 11.4 | Xcode 11.4 |
| 54 | Xcode 3.2 / Xcode 10.0 | Xcode 10 |
| 55 | Xcode 9.3 | Xcode 9.3 |
| 56 | Xcode 14.0 | Xcode 14 |
| 70 | Xcode 15.0 | Xcode 15 |
archiveVersion は常に 1 で変化しない。
objects はプロジェクト内の全オブジェクトを UUID キーで格納するフラットな辞書である。
objects = {
/* Begin PBXBuildFile section */
<UUID> /* name */ = { ... };
<UUID> /* name */ = { ... };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
<UUID> /* name */ = { ... };
/* End PBXFileReference section */
...
};
- ISA 名のアルファベット順にセクションが並ぶ(
PBX*→XC*) - 各セクションは
/* Begin XXX section */と/* End XXX section */で囲まれる - セクション間には空行が入る
- 各セクション内のエントリは UUID の昇順でソートされる
エントリの記述形式は ISA によって決まる:
インライン形式(1行)— PBXBuildFile, PBXFileReference, PBXFileSystemSynchronizedRootGroup:
3106FB61... /* file.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3106FB60... /* file.swift */; };
展開形式(複数行)— その他すべての ISA:
821507281E57468200C75711 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = ( ... );
runOnlyForDeploymentPostprocessing = 0;
};
- 24文字の16進大文字(96ビット):
3106FB6119A2B12000CCFAE6 - Xcode がオブジェクト作成時に自動生成する
- プロジェクト内で一意
- UUID の直後に
/* ... */コメントで人間が読める名前が付記される
3106FB60... /* ProtectedTests.swift */
配列要素やキーの値として UUID を参照する場合も同様にコメントが付く:
fileRef = 3106FB60... /* ProtectedTests.swift */;
objects 辞書内のセクション出現順(ISA 名アルファベット順)に記載する。
シェルスクリプト実行のみなど、直接のビルド成果物を持たない複合ターゲット。
A81D162B... /* SwiftLint */ = {
isa = PBXAggregateTarget;
buildConfigurationList = A81D162E... /* Build configuration list for PBXAggregateTarget "SwiftLint" */;
buildPhases = (
A81D162F... /* ShellScript */,
);
dependencies = (
);
name = SwiftLint;
productName = SwiftLint;
};
| キー | 説明 |
|---|---|
buildConfigurationList |
XCConfigurationList の UUID |
buildPhases |
ビルドフェーズの UUID 配列 |
dependencies |
PBXTargetDependency の UUID 配列 |
name |
ターゲット名 |
productName |
プロダクト名 |
ビルドフェーズにファイルを含めるための関連付け。1つのファイル参照×1つのフェーズの組み合わせを1件ずつ表す。同一ファイルが複数ターゲットに含まれる場合、複数の PBXBuildFile が同じ fileRef を参照する。
インライン形式で記述される。
3106FB61... /* file.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3106FB60... /* file.swift */; };
settings 付き(ヘッダの公開範囲指定):
01A0EAA8... /* SwiftFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 01A0EAA7... /* SwiftFormat.h */; settings = {ATTRIBUTES = (Public, ); }; };
platformFilters 付き:
018D0ACE... /* Euclid.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = ...; platformFilters = (ios, maccatalyst, tvos, xros, ); settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
| キー | 説明 |
|---|---|
fileRef |
PBXFileReference の UUID |
settings |
(任意)ATTRIBUTES 等を含む辞書 |
platformFilters |
(任意)プラットフォーム制限の配列 |
ATTRIBUTES の値: Public, Private, Project, CodeSignOnCopy, RemoveHeadersOnCopy
ターゲット依存関係のプロキシ。PBXTargetDependency から参照される。
2E4FEFE8... /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2E4FEFD2... /* Project object */;
proxyType = 1;
remoteGlobalIDString = 2E4FEFDA...;
remoteInfo = SwiftyJSON;
};
| キー | 説明 |
|---|---|
containerPortal |
PBXProject の UUID |
proxyType |
1 = ターゲット依存、2 = 外部プロジェクト参照 |
remoteGlobalIDString |
参照先ターゲットの UUID |
remoteInfo |
参照先ターゲット名 |
ファイルコピーフェーズ。フレームワークの埋め込み(Embed Frameworks)などに使用する。
018D0ACB... /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
018D0ACE... /* Euclid.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
| キー | 説明 |
|---|---|
buildActionMask |
常に 2147483647 |
dstPath |
コピー先サブパス |
dstSubfolderSpec |
コピー先フォルダ種別(下表) |
files |
PBXBuildFile の UUID 配列 |
name |
(任意)フェーズ名 |
runOnlyForDeploymentPostprocessing |
0 または 1 |
dstSubfolderSpec の値:
| 値 | コピー先 |
|---|---|
7 |
Resources |
10 |
Frameworks |
13 |
SharedSupport |
16 |
Plugins |
ファイルやビルド成果物への参照。インライン形式で記述される。
ソースファイル:
3106FB60... /* ProtectedTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProtectedTests.swift; sourceTree = "<group>"; };
ビルド成果物:
2987B0A5... /* AFNetworking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AFNetworking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
name と path が異なる場合:
297824A0... /* adn_0.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = adn_0.cer; path = ADNNetServerTrustChain/adn_0.cer; sourceTree = "<group>"; };
| キー | 説明 |
|---|---|
lastKnownFileType |
Xcode が推定したファイル種別(ソースファイル等) |
explicitFileType |
明示指定されたファイル種別(ビルド成果物等) |
path |
ファイルパス |
name |
(任意)表示名(path と異なる場合) |
sourceTree |
パスの基準(後述「sourceTree とパス解決」参照) |
fileEncoding |
(任意)ファイルエンコーディング |
includeInIndex |
(任意)0 = インデックスから除外 |
lastKnownFileType の主な値:
| 値 | ファイル種別 |
|---|---|
sourcecode.swift |
Swift ソース |
sourcecode.c.objc |
Objective-C ソース |
sourcecode.c.h |
C/Objective-C ヘッダ |
sourcecode.c.c |
C ソース |
sourcecode.cpp.objcpp |
Objective-C++ ソース |
sourcecode.cpp.h |
C++ ヘッダ |
file.storyboard |
Storyboard |
file.xib |
XIB |
image.png |
PNG 画像 |
text.plist.xml |
XML Property List |
text.plist.entitlements |
Entitlements |
text.xcconfig |
Xcode 設定ファイル |
text.json |
JSON |
text |
プレーンテキスト |
file |
不明なファイル |
folder |
フォルダ参照 |
folder.assetcatalog |
Asset Catalog |
wrapper.framework |
フレームワーク |
wrapper.xcframework |
XCFramework |
Xcode 15 以降で導入されたフォルダ同期グループ。指定パス配下のファイルをディスクと自動同期する。インライン形式で記述される。
2E3A24EE... /* Rules */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); name = Rules; path = Sources/Rules; sourceTree = SOURCE_ROOT; };
| キー | 説明 |
|---|---|
explicitFileTypes |
明示的なファイル種別指定(通常は空辞書) |
explicitFolders |
明示的なフォルダ指定(通常は空配列) |
name |
表示名 |
path |
ディスク上のパス |
sourceTree |
パスの基準 |
フレームワークリンクフェーズ(Link Binary With Libraries)。
82150727... /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
| キー | 説明 |
|---|---|
buildActionMask |
常に 2147483647 |
files |
PBXBuildFile の UUID 配列 |
runOnlyForDeploymentPostprocessing |
0 または 1 |
仮想的なグループ(Xcode のプロジェクトナビゲータに表示されるフォルダ構造)。
8215072D... /* iCarousel */ = {
isa = PBXGroup;
children = (
82150737... /* iCarousel.h */,
82150738... /* iCarousel.m */,
8215073B... /* Supporting Files */,
);
path = iCarousel;
sourceTree = "<group>";
};
name のみの場合(ディスク上のパスと対応しない仮想グループ):
8215072C... /* Products */ = {
isa = PBXGroup;
children = (
8215072B... /* iCarousel.framework */,
);
name = Products;
sourceTree = "<group>";
};
| キー | 説明 |
|---|---|
children |
子要素の UUID 配列(PBXGroup / PBXFileReference / PBXVariantGroup / PBXReferenceProxy が混在可) |
path |
(任意)ディスク上のパス |
name |
(任意)表示名(path と異なる場合、または path がない場合) |
sourceTree |
パスの基準 |
pathとnameは通常どちらか一方のみ- 両方ある場合は
pathが実パス、nameが表示名 - ルートグループ(mainGroup)は
pathもnameも省略されることがある
ヘッダコピーフェーズ。フレームワークターゲットで公開ヘッダを設定する際に使用する。
82150728... /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
82150739... /* iCarousel.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
通常のビルドターゲット(アプリ、フレームワーク、テスト等)。
2E4FEFDA... /* SwiftyJSON */ = {
isa = PBXNativeTarget;
buildConfigurationList = 2E4FEFF4... /* Build configuration list for PBXNativeTarget "SwiftyJSON" */;
buildPhases = (
2E4FEFD7... /* Sources */,
2E4FEFD8... /* Frameworks */,
2E4FEFD9... /* Headers */,
2E4FEFDA... /* Resources */,
);
buildRules = (
);
dependencies = (
A81D162D... /* PBXTargetDependency */,
);
name = SwiftyJSON;
productName = SwiftyJSON;
productReference = 2E4FEFDB... /* SwiftyJSON.framework */;
productType = "com.apple.product-type.framework";
};
| キー | 説明 |
|---|---|
buildConfigurationList |
XCConfigurationList の UUID |
buildPhases |
ビルドフェーズの UUID 配列(実行順) |
buildRules |
ビルドルール配列(通常は空) |
dependencies |
PBXTargetDependency の UUID 配列 |
name |
ターゲット名 |
productName |
プロダクト名 |
productReference |
ビルド成果物の PBXFileReference UUID |
productType |
プロダクト種別(下表) |
productType の値:
| 値 | 種別 |
|---|---|
com.apple.product-type.application |
アプリケーション |
com.apple.product-type.framework |
フレームワーク |
com.apple.product-type.library.static |
スタティックライブラリ |
com.apple.product-type.bundle.unit-test |
ユニットテスト |
com.apple.product-type.bundle.ui-testing |
UI テスト |
com.apple.product-type.tool |
コマンドラインツール |
com.apple.product-type.xcode-extension |
Xcode 拡張 |
buildPhases の順序は Xcode がビルド時に上から実行する順序に対応する。
プロジェクトルートオブジェクト。rootObject から参照され、プロジェクトに1件のみ存在する。
2E4FEFD2... /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 2620;
ORGANIZATIONNAME = Alamofire;
TargetAttributes = {
<target-UUID> = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0900;
ProvisioningStyle = Manual;
};
};
};
buildConfigurationList = <UUID> /* Build configuration list for PBXProject "..." */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = <UUID>;
productRefGroup = <UUID> /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
<UUID> /* TargetName */,
);
};
| キー | 説明 |
|---|---|
attributes |
プロジェクト属性(TargetAttributes 等を含む) |
buildConfigurationList |
XCConfigurationList の UUID |
compatibilityVersion |
互換性バージョン文字列 |
developmentRegion |
開発リージョン(en 等) |
hasScannedForEncodings |
エンコーディングスキャン済みフラグ |
knownRegions |
サポートするリージョン配列 |
mainGroup |
ルートグループの PBXGroup UUID |
productRefGroup |
Products グループの PBXGroup UUID |
projectDirPath |
プロジェクトディレクトリパス(通常は空) |
projectRoot |
プロジェクトルート(通常は空) |
targets |
ターゲットの UUID 配列 |
他プロジェクトのビルド成果物へのプロキシ参照。
<UUID> /* ProductName.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ProductName.framework;
remoteRef = <UUID> /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
| キー | 説明 |
|---|---|
fileType |
ファイル種別 |
path |
パス |
remoteRef |
PBXContainerItemProxy の UUID |
sourceTree |
パスの基準 |
リソースコピーフェーズ(Copy Bundle Resources)。
<UUID> /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
<UUID> /* Tests.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
シェルスクリプト実行フェーズ(Run Script)。
A81D162F... /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format Code";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/format.sh\"\n";
};
| キー | 説明 |
|---|---|
alwaysOutOfDate |
(任意)1 = 常に実行 |
files |
入力ファイル(通常は空) |
inputFileListPaths |
入力ファイルリストのパス配列 |
inputPaths |
入力パス配列 |
name |
(任意)フェーズ名 |
outputPaths |
出力パス配列 |
shellPath |
シェルのパス(通常 /bin/sh) |
shellScript |
実行するスクリプト(エスケープされた文字列) |
shellScript の値はクォート文字列であり、\n(改行)や \"(引用符)などのエスケープが含まれる。
ソースコンパイルフェーズ(Compile Sources)。
<UUID> /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
<UUID> /* SwiftyJSON.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
ターゲット間の依存関係。
<UUID> /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = <UUID> /* TargetName */;
targetProxy = <UUID> /* PBXContainerItemProxy */;
};
| キー | 説明 |
|---|---|
target |
依存先 PBXNativeTarget の UUID |
targetProxy |
PBXContainerItemProxy の UUID |
ローカライズされたファイルのグループ(Storyboard、XIB 等)。
<UUID> /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
<UUID> /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
| キー | 説明 |
|---|---|
children |
ローカライズ版 PBXFileReference の UUID 配列 |
name |
ファイル名 |
sourceTree |
パスの基準 |
ビルド設定(Debug / Release 等)。
<UUID> /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
PRODUCT_BUNDLE_IDENTIFIER = "org.example.App";
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
| キー | 説明 |
|---|---|
buildSettings |
ビルド設定キー・値の辞書 |
name |
設定名(Debug, Release 等) |
buildSettings の値は文字列または配列。Xcode のビルド設定キーを任意個列挙できる。
ビルド設定のリスト。PBXProject と各ターゲットに1つずつ存在する。
<UUID> /* Build configuration list for PBXProject "MyApp" */ = {
isa = XCConfigurationList;
buildConfigurations = (
<UUID> /* Debug */,
<UUID> /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
| キー | 説明 |
|---|---|
buildConfigurations |
XCBuildConfiguration の UUID 配列 |
defaultConfigurationIsVisible |
常に 0 |
defaultConfigurationName |
デフォルト設定名(通常 Release) |
Swift Package Manager のリモートパッケージ参照。
<UUID> /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pointfreeco/swift-snapshot-testing";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.8.2;
};
};
| キー | 説明 |
|---|---|
repositoryURL |
パッケージリポジトリの URL |
requirement |
バージョン要件(下表) |
requirement.kind の値:
| 値 | 説明 |
|---|---|
upToNextMajorVersion |
次のメジャーバージョン未満 |
upToNextMinorVersion |
次のマイナーバージョン未満 |
exactVersion |
完全一致 |
branch |
ブランチ指定 |
revision |
リビジョン(コミット)指定 |
Swift Package Manager のプロダクト依存。
<UUID> /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = <UUID> /* XCRemoteSwiftPackageReference "..." */;
productName = SnapshotTesting;
};
| キー | 説明 |
|---|---|
package |
XCRemoteSwiftPackageReference の UUID |
productName |
依存するプロダクト名 |
project.pbxproj の全オブジェクトは objects 辞書にフラットに格納されているが、UUID による参照でツリー構造を形成する。rootObject からすべてのオブジェクトをたどることができる。
rootObject
└─ PBXProject
├─ mainGroup ─→ PBXGroup(ルート)
│ ├─ PBXGroup(サブグループ)
│ │ ├─ PBXFileReference
│ │ └─ PBXVariantGroup
│ │ └─ PBXFileReference(ローカライズ版)
│ └─ PBXFileSystemSynchronizedRootGroup
│
├─ productRefGroup ─→ PBXGroup(Products)
│ └─ PBXFileReference(ビルド成果物)
│
├─ targets ─→ PBXNativeTarget / PBXAggregateTarget
│ ├─ buildPhases ─→ PBXSourcesBuildPhase
│ │ └─ files ─→ PBXBuildFile
│ │ └─ fileRef ─→ PBXFileReference
│ ├─ dependencies ─→ PBXTargetDependency
│ │ ├─ target ─→ PBXNativeTarget
│ │ └─ targetProxy ─→ PBXContainerItemProxy
│ └─ buildConfigurationList ─→ XCConfigurationList
│ └─ buildConfigurations ─→ XCBuildConfiguration
│
└─ buildConfigurationList ─→ XCConfigurationList(プロジェクトレベル)
└─ buildConfigurations ─→ XCBuildConfiguration
sourceTree はファイルパスの基準点を指定する。path と組み合わせて実際のディスク上のパスを決定する。
| sourceTree 値 | 基準 |
|---|---|
"<group>" |
親グループの解決済みパスからの相対パス |
SOURCE_ROOT |
プロジェクトファイル(.xcodeproj)の親ディレクトリ |
BUILT_PRODUCTS_DIR |
ビルド出力ディレクトリ |
SDKROOT |
SDK ルートディレクトリ |
DEVELOPER_DIR |
Xcode.app の Developer ディレクトリ |
"<group>" の場合、パス解決はルートグループから再帰的に行われる:
- ルートグループ(mainGroup)の
path(通常は空 = プロジェクトルート)を起点とする - 子グループの
pathを連結していく - 最終的な PBXFileReference の
pathを連結して実パスを得る
例: ルートグループ(path なし) → サブグループ(path = iCarousel) → ファイル(path = iCarousel.h) → 実パスは iCarousel/iCarousel.h
Xcode は ISA に応じて辞書の記述形式を使い分ける:
| 形式 | 対象 ISA |
|---|---|
| インライン(1行) | PBXBuildFile, PBXFileReference, PBXFileSystemSynchronizedRootGroup |
| 展開(複数行) | 上記以外のすべての ISA |
インライン形式は大量に存在するエントリ(ファイル参照、ビルドファイル)をコンパクトに記述するために使われる。展開形式は配列や入れ子辞書を含む構造的なオブジェクトに使われる。