PBXBuildFile与PBXFileReference
PBXBuildFile与PBXFileReference这两个section保存中工程文件相关的信息:包含文件的类型,路径,名称等
<code class="hljs avrasm has-numbering"><span class="hljs-comment">/* Begin PBXBuildFile section */</span> <span class="hljs-number">2</span>B82218D1B75AC8800BDEFB7 <span class="hljs-comment">/* Foundation.framework in Frameworks */</span> = {isa = PBXBuildFile<span class="hljs-comment">; </span> fileRef = <span class="hljs-number">2</span>B82218C1B75AC8800BDEFB7 <span class="hljs-comment">/* Foundation.framework */</span><span class="hljs-comment">; };</span> <span class="hljs-comment">/* End PBXBuildFile section */</span> <span class="hljs-comment">/* Begin PBXFileReference section * F60CC2A014D4EA0500A005E4 /* SocketOperation.m */</span> = {isa = PBXFileReference<span class="hljs-comment">; </span> lastKnownFileType = sourcecode<span class="hljs-preprocessor">.c</span><span class="hljs-preprocessor">.objc</span><span class="hljs-comment">; </span> sourceTree = <group><span class="hljs-comment">; };</span> <span class="hljs-comment">/* End PBXFileReference section */</span></code>
PBXGroup
这个section保存着工程文件的分组信息:分组的名称,以及该组内含有的文件,比如下面的例子,一个EGOTableViewPullRefresh分组里面还有一个children子分组,同时该组包含EGORefreshTableHeaderView的.h和.m两个文件,该分组对应的相对路径为../Classes/EGOTableViewPullRefresh
<code class="hljs cs has-numbering"> E1B4A9DE12FC8B1000EB3F67 <span class="hljs-comment">/* EGOTableViewPullRefresh */</span> = { isa = PBXGroup; children = ( E1B4A9DF12FC8B1000EB3F67 <span class="hljs-comment">/* EGORefreshTableHeaderView.h */</span>, E1B4A9E012FC8B1000EB3F67 <span class="hljs-comment">/* EGORefreshTableHeaderView.m */</span>, ); name = EGOTableViewPullRefresh; path = ../Classes/EGOTableViewPullRefresh; sourceTree = <span class="hljs-string">"<group>"</span>; }; <span class="hljs-comment">/* End PBXGroup section */</span></code>
PBXNativeTarget
该section保存工程创建的target信息:包含target的对应的配置信息、创建规则、依赖、名称和类型等信息
<code class="hljs cs has-numbering"><span class="hljs-comment">/* Begin PBXNativeTarget section */</span> <span class="hljs-number">1</span>D6058900D05DD3D006BFB54 <span class="hljs-comment">/* MyBaby */</span> = { isa = PBXNativeTarget; buildConfigurationList = <span class="hljs-number">1</span>D6058960D05DD3E006BFB54 <span class="hljs-comment">/* Build configuration list for PBXNativeTarget "MyBaby" */</span>; buildPhases = ( <span class="hljs-number">1</span>D60588D0D05DD3D006BFB54 <span class="hljs-comment">/* Resources */</span>, <span class="hljs-number">832</span>D4F01120A6F7C001708D4 <span class="hljs-comment">/* CopyFiles */</span>, <span class="hljs-number">1</span>D60588E0D05DD3D006BFB54 <span class="hljs-comment">/* Sources */</span>, <span class="hljs-number">1</span>D60588F0D05DD3D006BFB54 <span class="hljs-comment">/* Frameworks */</span>, <span class="hljs-number">79289</span>B3ECCA2441197B8D7F6 <span class="hljs-comment">/* Copy Pods Resources */</span>, ); buildRules = ( ); dependencies = ( ); name = MyBaby; productName = WordPress; productReference = <span class="hljs-number">1</span>D6058910D05DD3D006BFB54 <span class="hljs-comment">/* My Baby.app */</span>; productType = <span class="hljs-string">"com.apple.product-type.application"</span>; }; <span class="hljs-comment">/* End PBXNativeTarget section */</span></code>
XCBuildConfiguration与XCConfigurationList
这两个section保存着工程相关的配置信息:下面对应的是debug模式下的配置信息,可以看到里面包含CODE_SIGN_IDENTITY,sdk,framework的搜索路径等信息。
<code class="hljs objectivec has-numbering"><span class="hljs-comment">/* Begin XCBuildConfiguration section */</span> C01FCF5008A954540054247B <span class="hljs-comment">/* Release */</span> = { isa = XCBuildConfiguration; baseConfigurationReference = EBC24772E5CD4036B5AFD803 <span class="hljs-comment">/* Pods.xcconfig */</span>; buildSettings = { ARCHS = <span class="hljs-string">"$(ARCHS_STANDARD)"</span>; CODE_SIGN_ENTITLEMENTS = <span class="hljs-string">""</span>; CODE_SIGN_IDENTITY = <span class="hljs-string">""</span>; GCC_C_LANGUAGE_STANDARD = c99; GCC_THUMB_SUPPORT = <span class="hljs-literal">NO</span>; GCC_WARN_ABOUT_RETURN_TYPE = <span class="hljs-literal">YES</span>; GCC_WARN_UNUSED_VARIABLE = <span class="hljs-literal">YES</span>; HEADER_SEARCH_PATHS = <span class="hljs-string">""</span>; IPHONEOS_DEPLOYMENT_TARGET = <span class="hljs-number">7.0</span>; ONLY_ACTIVE_ARCH = <span class="hljs-literal">NO</span>; OTHER_CFLAGS = <span class="hljs-string">"-Wno-format-security"</span>; OTHER_LDFLAGS = ( <span class="hljs-string">"-lxml2"</span>, <span class="hljs-string">"-licucore"</span>, ); PROVISIONING_PROFILE = <span class="hljs-string">""</span>; SDKROOT = iphoneos; VALIDATE_PRODUCT = <span class="hljs-literal">YES</span>; VALID_ARCHS = <span class="hljs-string">"armv7 arm64 armv7s"</span>; }; name = Release; }; <span class="hljs-comment">/* End XCBuildConfiguration section */</span> <span class="hljs-comment">/* Begin XCConfigurationList section */</span> C01FCF4E08A954540054247B <span class="hljs-comment">/* Build configuration list for PBXProject "MyBaby" */</span> = { isa = XCConfigurationList; buildConfigurations = ( C01FCF4F08A954540054247B <span class="hljs-comment">/* Debug */</span>, C01FCF5008A954540054247B <span class="hljs-comment">/* Release */</span>, <span class="hljs-number">2</span>F30B4C10E342FDF00211B15 <span class="hljs-comment">/* Distribution */</span>, <span class="hljs-number">83</span>D3E0201215F89F00600B4B <span class="hljs-comment">/* Beta */</span>, ); defaultConfigurationIsVisible = <span class="hljs-number">0</span>; defaultConfigurationName = Release; }; <span class="hljs-comment">/* End XCConfigurationList section */</span></code>
通过上面分析一个pbxproj文件的过程可以看出,要创建一个工程,首先需要添加相关的文件,然后设置需要生成的target以及对应的配置信息就行了。