9

I have spent a long time looking for an answer regarding merge conflicts with project.pbxproj files. My merge conflicts mainly occur with Cocoapods. It seems that if I add a pod on a branch, then try to merge it into another, many many merge conflict arise in the project.pbxproj file of my Pods project. I would simply go trough and fix these conflicts manually, but there are way to many for this to be reasonable. Has anyone else encountered this problem and found a reasonable solution. This issue has plagued me for sometime now and I am only asking this question as a last resort. After creating a couple of new features on separate branches, having this much trouble including them into my project is very frustrating. Any help would be very much appreciated.

3 Answers 3

16

As long as you're not making changes, which you probably shouldn't be, to the Pods.xcodeproj file, then the source of truth is always what is generated with pod install. Therefore if there are many conflicts you can just delete the project and regenerate it.

3
  • Are you recommending removing the Pods.xcodeproj, then merge the files, then regenerate it or delete them, regenerate them then merge. I have tried both and this just moves the conflict from the Pods.xcodeproj project.pbxproj to my main profiles project.pbxproj.
    – ferris
    Nov 15, 2014 at 1:07
  • 3
    I'm recommending when you see a merge conflict, as long as you haven't edited them yourselves, delete the conflicted files and run pod install again. Nov 15, 2014 at 17:54
  • @KeithSmiley Thank you for your comment here, this solved my problem! May 10, 2017 at 15:28
0

I've run into this on a fairly regular basis. I have a recipe that works most of the time. We use Git-flow, so are typically trying to merge feature branches into develop. Memory being what it is, often the first time we notice this is when GitHub warns of a conflict.

  1. Commit (or stash) all outstanding work on your local feature branch.
  2. Run pod deintegrate (docs here)
  3. Commit the branch. It’s temporarily in an unusable state. This will be resolved momentarily.
  4. Switch to the latest develop
  5. Again, run pod deintegrate
  6. Commit changes to develop. Don’t push these changes up to origin. This commit will be deleted shortly.
  7. Switch back to your working branch.
  8. Merge in your local develop. Hopefully this will be conflict free.
  9. Run pod install, run the apps and check that everything works as expected.
  10. Commit the merge. Delete the local develop commit (i.e. git reset to origin)
  11. Push working branch changes.

You may also want to consider using a hook to prevent pushes of integrated projects. This puts the onus on the developer to pod deintegrate before pushing changes up (and also requires other developers to pod deintegrate before merging from develop) but does remove one potential source of conflicts if using a cloud repo provider that manages your workflow like GitHub.

It's also worth splitting out file-add operations into their own commit to reduce the noise.

0

Following by this guild: https://github.com/CocoaPods/CocoaPods/issues/3093

For CocoaPods to say that message, the project will have <<<<<<<, >>>>>>> or ======= on a line indicating it has a conflict which hasn't been resolved.

It is possible that there is still the conflict markers and the file is still in a conflict (git only says it's resolved because it was told it has been resolved regardless of the conflict markers).

You can find them in your file by running the following:

grep -E '<<<<<<<|>>>>>>>|=======' /path/to/project/project.pbxproj

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.