xcode iPhone Dev - Project.pbxproj 有多重要?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5931788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iPhone Dev - How important is Project.pbxproj?
提问by RyanJM
What does this file hold and how important is it to keep it "correct"?
这个文件有什么内容,保持它“正确”有多重要?
I've seen people write scriptsto just merge any change dealing with it and I've heard othersmerging it manually every time.
我见过有人编写脚本来合并处理它的任何更改,我听说其他人每次都手动合并它。
What is the correct way to handle it and why?
处理它的正确方法是什么,为什么?
回答by bbum
The project.pbxproj contains all of the metadata about your project that Xcode uses to build it; the settings, the file references, configuration, targeted platforms, etc...
project.pbxproj 包含 Xcode 用于构建它的项目的所有元数据;设置、文件引用、配置、目标平台等...
I.e. it is a critically important.
即它是一个非常重要的。
There really isn't a great answer for this. Typically, teams will avoid conflict by limiting edits to the project to one team member at a time.
真的没有一个很好的答案。通常,团队会通过将项目的编辑限制为一次仅限一名团队成员来避免冲突。
The Xcode team has put a lot of effort into making the file merge-friendly. In managing several large projects via svn, I've generally found that the merges are automatic and painless.
Xcode 团队付出了很多努力来使文件合并友好。在通过 svn 管理几个大型项目时,我通常发现合并是自动且轻松的。
Until they aren't. And when they aren't, revert, merge changes by hand (i.e. make the changes in the project that conflicted), and move on.
直到他们不是。当它们不是时,手动还原、合并更改(即在项目中进行冲突的更改),然后继续。
回答by Xiao
Try my script xUnique. What it does:
试试我的脚本xUnique。它能做什么:
- convert
project.pbxproj
to JSON format - Iterate all
objects
in JSON and give every UUID an absolute path, and create a new UUID using MD5 hex digest of the path- All elements in this json object is actually connected as a tree
- We give a path attribute to every node of the tree using its unique attribute; this path is the absolute path to the root node,
- Apply MD5 hex digest to the path for the node
- Replace all old UUIDs with the MD5 hex digest and also remove unused UUIDs that are not in the current node tree and UUIDs in wrong format
- Sort the project file inlcuding
children
,files
,PBXFileReference
andPBXBuildFile
list and remove all duplicated entries in these lists- see
sort_pbxproj
method in xUnique.py if you want to know the implementation; - It's ported from my modified
sort-Xcode-project-file
, with some differences in orderingPBXFileReference
andPBXBuildFile
- see
- With different options, you can use xUniquewith more flexibility
- 转换
project.pbxproj
为 JSON 格式 objects
在 JSON 中迭代所有内容并给每个 UUID 一个绝对路径,并使用路径的 MD5 十六进制摘要创建一个新的 UUID- 这个json对象中的所有元素实际上都是连接成一棵树
- 我们使用其唯一属性为树的每个节点赋予路径属性;这个路径是根节点的绝对路径,
- 将 MD5 十六进制摘要应用于节点的路径
- 用 MD5 十六进制摘要替换所有旧的 UUID,并删除不在当前节点树中的未使用的 UUID 和格式错误的 UUID
- 排序项目文件计有
children
,files
,PBXFileReference
和PBXBuildFile
列表,并删除这些列表中的所有重复的条目sort_pbxproj
如果您想了解实现,请参阅xUnique.py 中的方法;- 它是从我的修改版移植过来的
sort-Xcode-project-file
,在排序PBXFileReference
和PBXBuildFile
- 通过不同的选项,您可以更灵活地使用xUnique