xcode中的git project.pbxprojj冲突怎么解决

2313人阅读
移动开发(5)
& & & 因为项目的需求,最近学习了一下project.pbxproj,对于这个文件的介绍,网上有不少资料,但感觉都不甚详细,这里对我在学习中,学到的一些东西,稍作记录,一方面方便新学的同学能有个了解,同时也让自己以后,有个参考。
& & xcode将我们对项目的配置信息,统一写到了project.pbxproj文件里,一般情况下,我们是不需要直接和project.pbxproj打交道的,我们通过编辑xcode里面的选项,如buildsetting,general来修改pbxproj文件,如下图所示:
& & &但是,在一些情况下,我们为了方便、或者为了避免冲突,(尤其在多人协作的情况下),可能需要动态的修改pbxproj文件里面的内容,这个时候,我们就有必要了解一些project.pbxproj文件的构成了。
pbxproj文件主要包含了以下几项主要信息
工程文件关联信息,如PBXBuildFile、PBXFileReference
组织结构分类信息,如PBXGroup
项目工程配置信息,如XCBuildConfiguration、XCConfigurationList这里主要介绍项目工程配置信息。
查看工程的pbxproj文件的方法:找到工程文件,也就是yourproject.xcodeproj,右键,显示包内内容即可。
1、XCConfigurationList
& & & &这个部分,主要是target,以及project的一些基本信息,通常一个project会对应一个或者多个target,而每个target以及project本身的配置都会不同的,相应的,在pbxproj文件中,需要将这几个部分区分开来。如下图:
上图是一个demo工程里的XCConfigurationList。这个工程有一个project PBXProject &NSUrlSession& ,两个target, 分别是
PBXNativeTarget &NSUrlSession&&PBXNativeTarget &NSUrlSessionTests& 每个部分,都包含了debug release两部分,且都有相对应的id。这些uuid是每个target 相应的CONFIGURATION配置下的唯一标识。
2、XCBuildConfiguration
& & 这个部分,记录了project以及每个target具体的配置信息,以上面的例子为例,你想看知道target NSUrlSession debug对应的配置信息,你可以根据其相应的id(62A4BA691BCEF),去找到其相应的配置,&
buildsetting下面保存了我们在xcode 的buildsetting里面,对该target 的debug所设置的所有信息。如果你想知道每个键值对具体对于那个选项,你可以在buildsetting对某一项进行更改,然后diff一下pbxproj文件即可。
& & & &在大致了解了pbxproj文件的结构后,你就可以开始做一些比较灵活的更改了,比如,我们在开发过程中,可能需要构建release、dailybuild等不同的ipa,每个ipa都包含不同的provisioning文件。针对某种情况,在构建过程总,手动选择不同的证书,显然太麻烦了,现在根据我们上面的知识,我们知道,我们使用xcode对项目进行配置,所有的配置结果最终都会保存到pbxproj文件里面,同样的,provisioning选项,也保存在其中。那么,我们在build之前,根据不同的CONFIGURATION,修改pbxproj文件中相应的provisioning文件,就能够达到修改provisioning配置的目的,自动的实现上述过程。
& & &还以上面的例子来说,假如,我要在build之前,更改debug的provision,只需要把这个键值对改成自己希望的样子即可。
& & 以下为实现的脚本
functhParam(){
orgin=$(grep -i -n $1 $filepath | head -n
1 | awk -F ':'
'{print $1}')
count=$(grep -i -A 200 $1 $filepath | grep -i -n
'PROVISIONING_PROFILE' | head -n
1 |awk -F ':'
'{print $1}')
let line=$orgin+count-1
echo $line
sed -i '' $line&s/^.*/$2/g& $filepath
functhParam &^.*62A4BA691BCEF.*=&
'PROVISIONING_PROFILE = &4173f94a-df88-e-1e40f83cdd21&;'
这样,就在脚本中,将debug的provisioning绑定为4173f94a-df88-e-1e40f83cdd21了。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:4264次
排名:千里之外
(2)(2)(1)(1)Automatically resolving git merge conflicts in Xcode’s project.pbxproj file | Roadfire Softwareiphone - How to merge conflicts (file project.pbxproj) in Xcode use svn? - Stack Overflow
to customize your list.
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
There are 2 members in our team. We use Xcode's SCM (use SVN) to manger our source code files. We all add files to our Xcode project. He has commited to svn server. When I update, Xcode find there has conflicts in project.pbxproj file.Then I select quit Xcode and manual merge the conflicts. Then I
start to edit my project.pbxproj, merge our changes. Actually I don't konw how Xcode manage files, I just add some text that my
project.pbxproj file did't had. When I finish it, my project can't open. I guess that because the project.pbxproj file can't be edit by manual.
So, I want to know, when you find this problem, the project.pbxproj file have conflicts, how to solve it?
Thank you!
Unfortunately, there's not much you can do except to make the changes manually in one check out and then check-in the newly "merged" project.
92.2k20154194
I use git but we see the same issue - if two people add files there's a merge conflict.
Usually the editing is very easy though.
Simply go into the project.pbxproj file with a text editor, and look for the merge conflict section - usually this is marked by something like :
In 99% of Xcode project merge conflict cases, you simply want to accept both sides of the merge (because two people added different files) - so you would simply delete the merge markers, in the above case that would end up like:
Like I said, this works great in MOST cases.
If Xcode will not read the project file when you are done, just take the most recent un-merged version and manually add your files again.
11.8k34374
64.2k24106133
I was looking for a straightforward solution to this problem when I came across this other question/answer:
I was completely blown away by how simple this solution is, I was trying to merge in a disparate feature branch which was almost 200 revisions behind the trunk, XCode and Mercurial were not being happy campers about it.
I tried manually merging the pbxproj file (which had over 100 conflicts) 8 times before trying this solution.
Basically the solution is as such (assuming you use Mercurial, because it's awesome):
Attempt your merge in mercurial:
hg update FEATURE_BRANCH
hg merge default
*mercurial gives you a ton of crap about the pbxproj file having merge conflicts*
Open Xcode
From the top toolbar, select Xcode->Open Developer Tool->FileMerge
On the left, open your conflicted 'project.pbxproj' file (the one with merge conflict markup in it)
On the right side, open your 'project.pbxproj.orig'
Select File->Save Merge and save over the 'project.pbxproj' file
Then back at the command line:
hg resolve -m ProjectName.xcodeproj/project.pbxproj
*merge any other broken files*
hg commit -m "manually merged with trunk"
Eat Cake Because You Are Done
Sometimes one or few files could be recreated (for example ManagedObjects) in different branches , so when you'll merge there may be two declarations for one file in one block. In this case you should delete one of the declarations.
As stated above the most common way of handling the conflicts is to
accept "everything"
re-import the files into the project
I Wrote a bash-script that takes care of (1) above.
Note that this will only solve the most common case of merge conflicts!
#!/bin/bash
if [ $# -eq 0 ]
echo "File must be provided as argument, darnit!"
if [ $# -eq 2 ]
echo "only ONE File must be provided as argument, darnit!"
echo "Will remove lines from file:" $1
grep -v "&&&&&" $1
| grep -v "&&&&&&" | grep -v "====" & out.mv out.tmp $1
echo "Done removing lines from file:" $1
I founded a tool "xUnique" , it works!
This solution is only for git, but you can add a .gitattributes file to your project then within that file add the following line:
*.pbxproj merge=union
This will tell git to keep both sides of the merge which will be what you want the vast majority of the time.
The best thing to do might be to simply accept either your version or his version in its entirety, without trying to combine the two.
Also, consider whether the file in question is something that should be in t it may be more appropriate to let each person have their own version of it.
Check out the
on how to resolve conflicts.
7,43521627
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledxcode中的project.pbxproj冲突怎么解决_百度知道向Xcode项目添加.a库, project.pbxproj需要怎么修改?
有两个project, 把一个编译成.a文件, 现在想添加到另外一个project里面, 不用Xcode的界面方式, 想用脚本或者命令行实现, 需要怎么修改project.pbxproj文件?
已有帐号?
无法登录?
社交帐号登录}

我要回帖

更多关于 project.pbxproj 解析 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信