iOS - git merge conflicts after adding cocoapods to project

21,058

Solution 1

When git encounters merge conflicts, it adds lines of text to the conflicting files. They're comments like:

<<<<< HEAD
  ... your code from HEAD...
=========
  ... your code from the merge branch...
>>>>>> my_merged_branch_name

These lines mark where Git needs help. When Xcode runs into one of these lines in a .pbxproj file, it is unable to open the file and it throws an Workspace Inconsistency error.

If you look at the messages you got from git, they show which files had the merge conflicts.

To fix the problem:

  1. Open each of those file with a simple text editor (I'm old school, so I use vi. Nano will also work. Just make sure you use a code editor and not word processor like TextEdit that will try to change your line endings, etc. )

  2. Resolve the conflicts by removing the comment lines added by git, and deciding which lines of code to keep.

  3. Then tell git that you have resolved the conflicts: git add .

  4. and continue with the merge.

Xcode should now be able to open your project.

Solution 2

Here is my 2 Cents.

Sometimes even after deleting all of the >>>> and ===== still you get the same errors.

  • Clean the project,
  • Run the pod install
  • Build the project

This should fix the remaining issues.

Share:
21,058
user3344977
Author by

user3344977

Updated on July 05, 2022

Comments

  • user3344977
    user3344977 almost 2 years

    I'm working on an app with another partner. He's been working on master, and I started a new branch. On my branch I installed cocoapods. I just tried pulling from master and I'm getting merge conflicts.

    When I open up Xcode, the workspace file has an error and it says:

    "Workspace Integrity - Couldn't load project"
    

    How can I solve this merge conflict?

  • Kutay Demireren
    Kutay Demireren almost 9 years
    How can we look at the messages we got from git? You told like that, but I can't find. Glad if you can help.
  • Suz
    Suz almost 9 years
    Ah. Hmm. I use Git from the command line, so it prints a message when there's a merge conflict. However, the text >>>> and ===== are not messages. Git actually adds those lines to your code. To fix the conflict, you have to remove those lines (and adjust your code if you need to). When those lines are added to a .pbxproj file, Xcode gives the error in the question title. Just open up the .pbxproj file and search for >>>>.
  • Kutay Demireren
    Kutay Demireren almost 9 years
    Yeah okay, I mean, I was looking for a list of conflicting files. I explicitly each my file because I couldn't get that list, including pbxproj too. Anyway, thanks, you made it work
  • WDC
    WDC over 7 years
    I meet the same issue because i deleted a more semicolon when i fix merge conflict.