如何在Xcode中使用svn合并冲突(file project.pbxproj) ?

时间:2023-01-16 15:30:07

There are two 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 committed to SVN server. When I update, Xcode find there has conflicts in project.pbxproj file. Then I select quit Xcode and manually merge the conflicts. Then I start to edit my project.pbxproj, merge our changes. Actually I don't know how Xcode manage files, I just add some text that my project.pbxproj file did't have. When I finish, my project can't open. I guess that because the project.pbxproj file can't be edit by manual.

我们队有两名队员。我们使用Xcode的SCM(使用SVN)来管理我们的源代码文件。我们都向我们的Xcode项目添加文件。他已经提交了SVN服务器。当我更新时,Xcode发现项目中存在冲突。pbxproj文件。然后我选择quit Xcode并手动合并冲突。然后我开始编辑我的项目。pbxproj,合并更改。实际上我不知道Xcode是如何管理文件的,我只是添加了一些我的项目的文本。pbxproj文件确实没有。当我完成时,我的项目不能打开。我猜是因为这个项目。pbxproj文件不能手动编辑。

So, I want to know, when you find this problem, the project.pbxproj file have conflicts, how to solve it?

所以,我想知道,当你发现这个问题的时候,这个项目。pbxproj文件有冲突,如何解决?

Thank you!

谢谢你!

8 个解决方案

#1


17  

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.

不幸的是,除了在一个check out中手动进行更改,然后签入新“合并”的项目之外,您没有什么可以做的。

#2


120  

I use git but we see the same issue - if two people add files there's a merge conflict.

我使用git,但是我们看到了同样的问题——如果两个人添加文件,就会产生合并冲突。

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 :

通常编辑起来很容易。直接进入项目。使用文本编辑器的pbxproj文件,并查找合并冲突部分——通常是这样标记的:

>>>>>>>
Stuff 1
======
Stuff 2
<<<<<<<<

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:

在99%的Xcode项目合并冲突案例中,您只想接受合并的两个方面(因为两个人添加了不同的文件)——因此您只需删除合并标记,在上面的例子中,最终的结果是:

Stuff 1
Stuff 2

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.

就像我说的,这在大多数情况下都很有效。如果Xcode在完成后不会读取项目文件,那么只需使用最近的未合并版本,然后再次手动添加文件。

#3


4  

This solution is only for git, but you can add a .gitattributes file to your project then within that file add the following line:

此解决方案仅适用于git,但您可以向项目中添加.gitattributes文件,然后在该文件中添加以下一行:

*.pbxproj merge=union

*。pbxproj合并=联盟

This will tell git to keep both sides of the merge which will be what you want the vast majority of the time.

这将告诉git保持合并的两边,这在大多数情况下都是您想要的。

#4


3  

I was looking for a straightforward solution to this problem when I came across this other question/answer:

当我遇到另一个问题/答案时,我正在寻找一个直接的解决方法:

https://*.com/a/14180388/307217

https://*.com/a/14180388/307217

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.

我完全被这个解决方案的简单性所折服,我试图合并到一个完全不同的特性分支中,在主干、XCode和Mercurial后面大约有200个版本。在尝试此解决方案之前,我尝试了8次手动合并pbxproj文件(冲突超过100次)。

Basically the solution is as such (assuming you use Mercurial, because it's awesome):

基本的解决方案是这样的(假设你使用的是水银,因为它非常棒):

  1. 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*
    
  2. Open Xcode

    打开Xcode

  3. From the top toolbar, select Xcode->Open Developer Tool->FileMerge
  4. 在顶部工具栏中,选择Xcode->Open Developer Tool-> filemergence
  5. On the left, open your conflicted 'project.pbxproj' file (the one with merge conflict markup in it)
  6. 在左边,打开你的冲突项目。pbxproj'文件(其中包含合并冲突标记)
  7. On the right side, open your 'project.pbxproj.orig'
  8. 在右边,打开你的“项目。pbxproject。orig”
  9. Select File->Save Merge and save over the 'project.pbxproj' file
  10. 选择File->保存合并并保存“项目”。pbxproj”文件
  11. 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"
    
  12. Eat Cake Because You Are Done
  13. 吃蛋糕,因为你做完了。

#5


1  

As stated above the most common way of handling the conflicts is to

如上所述,处理冲突的最常见方法是

  1. accept "everything"
  2. 接受“一切”
  3. re-import the files into the project
  4. 重新导入文件到项目中

I Wrote a bash-script that takes care of (1) above.

我写了一个base -script来处理上面的(1)。

Note that this will only solve the most common case of merge conflicts!

请注意,这只会解决合并冲突最常见的情况!

#!/bin/bash
#
#
#
if [ $# -eq 0 ]
 then
    echo "File must be provided as argument, darnit!"
    exit 1
fi

if [ $# -eq 2 ]
 then
    echo "only ONE File must be provided as argument, darnit!"
    exit 1
fi


echo "Will remove lines from file:" $1
grep -v "<<<<<" $1  | grep -v ">>>>>>" | grep -v "====" > out.tmp;mv out.tmp $1
echo "Done removing lines from file:" $1

#6


1  

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.

有时,可以在不同的分支中重新创建一个或几个文件(例如ManagedObjects),因此当您合并时,一个块中的一个文件可能有两个声明。在这种情况下,您应该删除其中一个声明。

#7


-1  

I founded a tool "xUnique" https://github.com/truebit/xUnique, it works!

我创建了一个工具“xUnique”,它可以工作!

#8


-20  

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 the repository at all; it may be more appropriate to let each person have their own version of it.

最好的做法可能是简单地接受你的版本或他的版本的全部,而不是试图将两者结合起来。此外,考虑所涉及的文件是否应该存在于存储库中;让每个人都有自己的版本可能更合适。

Check out the documentation on how to resolve conflicts.

查看关于如何解决冲突的文档。

#1


17  

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.

不幸的是,除了在一个check out中手动进行更改,然后签入新“合并”的项目之外,您没有什么可以做的。

#2


120  

I use git but we see the same issue - if two people add files there's a merge conflict.

我使用git,但是我们看到了同样的问题——如果两个人添加文件,就会产生合并冲突。

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 :

通常编辑起来很容易。直接进入项目。使用文本编辑器的pbxproj文件,并查找合并冲突部分——通常是这样标记的:

>>>>>>>
Stuff 1
======
Stuff 2
<<<<<<<<

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:

在99%的Xcode项目合并冲突案例中,您只想接受合并的两个方面(因为两个人添加了不同的文件)——因此您只需删除合并标记,在上面的例子中,最终的结果是:

Stuff 1
Stuff 2

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.

就像我说的,这在大多数情况下都很有效。如果Xcode在完成后不会读取项目文件,那么只需使用最近的未合并版本,然后再次手动添加文件。

#3


4  

This solution is only for git, but you can add a .gitattributes file to your project then within that file add the following line:

此解决方案仅适用于git,但您可以向项目中添加.gitattributes文件,然后在该文件中添加以下一行:

*.pbxproj merge=union

*。pbxproj合并=联盟

This will tell git to keep both sides of the merge which will be what you want the vast majority of the time.

这将告诉git保持合并的两边,这在大多数情况下都是您想要的。

#4


3  

I was looking for a straightforward solution to this problem when I came across this other question/answer:

当我遇到另一个问题/答案时,我正在寻找一个直接的解决方法:

https://*.com/a/14180388/307217

https://*.com/a/14180388/307217

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.

我完全被这个解决方案的简单性所折服,我试图合并到一个完全不同的特性分支中,在主干、XCode和Mercurial后面大约有200个版本。在尝试此解决方案之前,我尝试了8次手动合并pbxproj文件(冲突超过100次)。

Basically the solution is as such (assuming you use Mercurial, because it's awesome):

基本的解决方案是这样的(假设你使用的是水银,因为它非常棒):

  1. 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*
    
  2. Open Xcode

    打开Xcode

  3. From the top toolbar, select Xcode->Open Developer Tool->FileMerge
  4. 在顶部工具栏中,选择Xcode->Open Developer Tool-> filemergence
  5. On the left, open your conflicted 'project.pbxproj' file (the one with merge conflict markup in it)
  6. 在左边,打开你的冲突项目。pbxproj'文件(其中包含合并冲突标记)
  7. On the right side, open your 'project.pbxproj.orig'
  8. 在右边,打开你的“项目。pbxproject。orig”
  9. Select File->Save Merge and save over the 'project.pbxproj' file
  10. 选择File->保存合并并保存“项目”。pbxproj”文件
  11. 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"
    
  12. Eat Cake Because You Are Done
  13. 吃蛋糕,因为你做完了。

#5


1  

As stated above the most common way of handling the conflicts is to

如上所述,处理冲突的最常见方法是

  1. accept "everything"
  2. 接受“一切”
  3. re-import the files into the project
  4. 重新导入文件到项目中

I Wrote a bash-script that takes care of (1) above.

我写了一个base -script来处理上面的(1)。

Note that this will only solve the most common case of merge conflicts!

请注意,这只会解决合并冲突最常见的情况!

#!/bin/bash
#
#
#
if [ $# -eq 0 ]
 then
    echo "File must be provided as argument, darnit!"
    exit 1
fi

if [ $# -eq 2 ]
 then
    echo "only ONE File must be provided as argument, darnit!"
    exit 1
fi


echo "Will remove lines from file:" $1
grep -v "<<<<<" $1  | grep -v ">>>>>>" | grep -v "====" > out.tmp;mv out.tmp $1
echo "Done removing lines from file:" $1

#6


1  

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.

有时,可以在不同的分支中重新创建一个或几个文件(例如ManagedObjects),因此当您合并时,一个块中的一个文件可能有两个声明。在这种情况下,您应该删除其中一个声明。

#7


-1  

I founded a tool "xUnique" https://github.com/truebit/xUnique, it works!

我创建了一个工具“xUnique”,它可以工作!

#8


-20  

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 the repository at all; it may be more appropriate to let each person have their own version of it.

最好的做法可能是简单地接受你的版本或他的版本的全部,而不是试图将两者结合起来。此外,考虑所涉及的文件是否应该存在于存储库中;让每个人都有自己的版本可能更合适。

Check out the documentation on how to resolve conflicts.

查看关于如何解决冲突的文档。