user3344977
user3344977

Reputation: 3604

iOS - git merge conflicts after adding cocoapods to project

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?

Upvotes: 19

Views: 22105

Answers (5)

OhadM
OhadM

Reputation: 4803

Most chances you have an issue with the project.pbxproj file which is inside your ProjectName.xcodeproj (right click show package content).

You can read up in github about a similar issue and there's also a "lint" solution you can try.

I think a faster solution would be moving the HEAD "backwards" in git over each commit until your project file works and once it works, move the HEAD 1 commit "forward" and see the changes in project.pbxproj, you will probably see missing closing/opening brackets or perhaps missing semicolon.

Now, that you know what is missing, go to the latest commit and manually fix your project.pbxproj file using a simple text viewer.

Good luck.

Upvotes: 0

Sanket Ray
Sanket Ray

Reputation: 1141

One more way to resolve conflicts, when you cannot access workspace files is to press + + c and should see every single conflict which leads to the error "Workspace Integrity - Couldn't load project".

If you are not sure what's wrong with pods or Carthage; you can right-click on pod/Carthage and discard changes. You can later update those pods manually.

Upvotes: 0

WDC
WDC

Reputation: 1

Maybe your project.pbxproj is destoryed. if you changed your project.pbxproj,you should check your project.pbxproj carefully by your.xcodeproj -->show Package contents -->project.pbxproj

Upvotes: 0

Mr H
Mr H

Reputation: 5304

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.

Upvotes: 9

Suz
Suz

Reputation: 3802

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.

Upvotes: 31

Related Questions