19

I have always solved this problem by using a merge strategy of the other members directory structure shall prevail, then confirming that there are no conflicts and mending it to what directory structure I want.

But is there another better way to resolve conflicts when merging the project.pbxproj file?

TT--
  • 2,956
  • 1
  • 27
  • 46
iforvert
  • 310
  • 1
  • 3
  • 10
  • 1
    No easy answer to that, however it will be difficult to solve, given the file is not designed to be human readable (it's perfectly editable, sure, but it doesn't make much sense, using UUIDs to link between sections). – trojanfoe May 24 '16 at 08:21
  • 1
    http://stackoverflow.com/questions/2004135/how-to-merge-conflicts-file-project-pbxproj-in-xcode-use-svn – Asim K T May 24 '16 at 09:56
  • @AsimKT 's question is about SVN but there's a great answer for Git among the answers: http://stackoverflow.com/a/2007358/2003763 – Thibault D. May 24 '16 at 10:11
  • I usually edit the file by hand. It's trivial in most cases. If you fail you can always cancel your merge and retry. I also tried using external merge tools like p4merge but if these tools are very efficient for code files, they sometimes make it worse when it comes to `pbxproj` files. – Thibault D. May 24 '16 at 10:13
  • I noticed that, and found the git related answer, that's why I commented it. – Asim K T May 24 '16 at 10:19
  • 1
    @ThibaultD's answer is what I wanted. Thanks a lot.http://stackoverflow.com/questions/2004135/how-to-merge-conflicts-file-project-pbxproj-in-xcode-use-svn/2007358#2007358 – iforvert May 27 '16 at 06:31
  • The best tool to solve conflicts there is Kdiff3. Give a try. – fjtrujy Jun 01 '17 at 14:32
  • Does this answer your question? [Merge conflicts with project.pbxproj on Git - Xcode iOS](https://stackoverflow.com/questions/31541624/merge-conflicts-with-project-pbxproj-on-git-xcode-ios) – TT-- Jun 07 '23 at 03:37
  • see also: https://stackoverflow.com/questions/2004135/how-to-merge-conflicts-file-project-pbxproj-in-xcode-use-svn – TT-- Jun 07 '23 at 03:46

1 Answers1

32

Normally, you simply want to accept both sides of the merge (people added different files) and that's all.

After that, if your file is still 'corrupted', in most cases the problem is due to a wrong format after merge, most common scenarios are:

  • missing a comma
  • duplicated statements

It's very easy to fix if you know what you are looking.

You can use a syntax checker to verify the project.pbxproj file, I use Kin and it works like a charm. It will parse your project configuration file and detect errors.


For Example (Using KIN)

If your project file gets corrupted you can be left with something like this:

enter image description here

And if your diffs on the file are far too much.. it can be quite challenging to find the error...now, after using KIN you can go from problem to solution in no time.

enter image description here

Hugo Alonso
  • 6,684
  • 2
  • 34
  • 65
Ana Llera
  • 1,376
  • 16
  • 32