简体   繁体   English

Cocoapods project.pbxproj 合并冲突

[英]Cocoapods project.pbxproj merge conflicts

I have spent a long time looking for an answer regarding merge conflicts with project.pbxproj files.我花了很长时间寻找有关与 project.pbxproj 文件合并冲突的答案。 My merge conflicts mainly occur with Cocoapods.我的合并冲突主要发生在 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.看来,如果我在一个分支上添加一个 pod,然后尝试将其合并到另一个分支中,我的 Pods 项目的 project.pbxproj 文件中会出现许多合并冲突。 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.任何帮助将不胜感激。

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 .只要您没有对Pods.xcodeproj文件进行更改(您可能不应该这样做),那么事实来源始终是pod install生成的内容。 Therefore if there are many conflicts you can just delete the project and regenerate it.因此,如果有很多冲突,您可以删除该项目并重新生成它。

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 .我们使用 Git-flow,因此通常会尝试将功能分支合并到develop Memory being what it is, often the first time we notice this is when GitHub warns of a conflict.内存就是它,通常我们第一次注意到这是 GitHub 警告冲突的时候。

  1. Commit (or stash) all outstanding work on your local feature branch.在本地功能分支上提交(或存储)所有未完成的工作。
  2. Run pod deintegrate ( docs here )运行pod deintegrate此处为文档
  3. Commit the branch.提交分支。 It's temporarily in an unusable state.它暂时处于无法使用的状态。 This will be resolved momentarily.这将暂时得到解决。
  4. Switch to the latest develop切换到最新develop
  5. Again, run pod deintegrate再次运行pod deintegrate
  6. Commit changes to develop .提交更改以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 .合并到您的本地develop Hopefully this will be conflict free.希望这将是无冲突的。
  9. Run pod install , run the apps and check that everything works as expected.运行pod install ,运行应用程序并检查一切是否按预期工作。
  10. Commit the merge.提交合并。 Delete the local develop commit (ie git reset to origin)删除本地develop提交(即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.这使开发人员有责任在推动更改之前pod deintegrate (并且还要求其他开发人员在develop合并之前pod deintegrate ),但如果使用像 GitHub 这样管理您的工作流的云存储库提供商,则确实消除了一个潜在的冲突源。

It's also worth splitting out file-add operations into their own commit to reduce the noise.将文件添加操作拆分为自己的提交以减少噪音也是值得的。

Following by this guild: https://github.com/CocoaPods/CocoaPods/issues/3093本公会关注: 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.对于 CocoaPods 来说,该项目将在一行上显示<<<<<<<, >>>>>>>=======表示它存在尚未解决的冲突。

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).可能仍然存在冲突标记并且文件仍然存在冲突(git 只说它已解决,因为它被告知无论冲突标记如何都已解决)。

You can find them in your file by running the following:您可以通过运行以下命令在您的文件中找到它们:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM