合并 Xcode 项目文件

发布于 2024-09-29 06:20:30 字数 1282 浏览 3 评论 0原文

合并分支时(我使用的是 git),Xcode 项目文件(Project.xcodeproj/project.pbxproj)中经常会出现冲突。有时这很容易,但有时我最终会得到一个损坏的项目文件并且必须恢复。在最坏的情况下,我必须通过拖入文件等方式在第二次提交中手动修复项目文件(可以与前一次提交一起压缩)。

有没有人有关于如何处理大型复杂文件(如 Xcode)中的合并冲突的提示项目文件?


编辑--一些相关问题:

Git 和 pbxproj

我应该使用 merge=union 将 .pbxproj 文件与 git 合并吗?

资源:

http://www.alphaworks.ibm.com/tech/xmldiffmerge< /a>

http://www2.informatik.hu-berlin.de/ ~obecker/XSLT/#merge

http://tdm.berlios.de/ 3dm/doc/thesis.pdf

http://www.cs.hut。 fi/~ctl/3dm/

http ://el4j.svn.sourceforge.net/viewvc/el4j/trunk/el4j/framework/modules/xml_merge/

There are often conflicts in the Xcode project file (Project.xcodeproj/project.pbxproj) when merging branches (I'm using git). Sometimes it's easy, but at times I end up with a corrupt project file and have to revert. In the worst case I have to fix up the project file manually in a second commit (which can be squashed with the previous) by dragging in files etc.

Does anyone have tips for how to handle merge conflicts in big and complex files like the Xcode project file?


EDIT-- Some related questions:

Git and pbxproj

Should I merge .pbxproj files with git using merge=union?

RESOURCES:

http://www.alphaworks.ibm.com/tech/xmldiffmerge

http://www2.informatik.hu-berlin.de/~obecker/XSLT/#merge

http://tdm.berlios.de/3dm/doc/thesis.pdf

http://www.cs.hut.fi/~ctl/3dm/

http://el4j.svn.sourceforge.net/viewvc/el4j/trunk/el4j/framework/modules/xml_merge/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

沙与沫 2024-10-06 06:20:32

我发现的最好方法是指示 Git 将 .pbxproj 文件视为二进制文件。这可以防止混乱的合并。

将其添加到您的 .gitatributes 文件中:

*.pbxproj -crlf -diff -merge

The best way I have found is to instruct Git to treat the .pbxproj file as a binary. This prevents messy merges.

Add this to your .gitatributes file:

*.pbxproj -crlf -diff -merge
柏拉图鍀咏恒 2024-10-06 06:20:32

要比较两个 Xcode 项目,请打开 FileMerge(打开 xcode 并选择 Xcode(从菜单窗格中)--> 打开开发人员工具--> FileMerge)。
现在单击“左”按钮并打开 xcode 项目主目录。
单击“右键”按钮并打开xcode项目主目录进行比较。

现在点击“合并”按钮!

就是这样!

To compare two Xcode projects open open FileMerge (open xcode and select Xcode (from the manu pane) --> Open developer tools --> FileMerge).
now click "left" button and open xcode project main directory.
click "right" button and open xcode project main directory to compare.

Now click "merge" button!

Thats it!

明媚殇 2024-10-06 06:20:32

考虑另一个选项,这可能有助于减少您遇到问题的次数。为了解释一下,我将团队成员的分支来自“开发”分支。
在您的团队中有一个约定,即当修改项目文件时,更改(以及确保构建完整性所需的任何其他更改)将在单独的提交中提交。然后该提交被挑选到开发分支上。计划修改分支中的项目文件的其他团队成员可以选择进入他们的分支或根据最新的开发重新调整他们的分支。这种方法需要整个团队的沟通和一些纪律。正如我所说,这并不总是可能的;在某些项目上它可能有很大帮助,而在某些项目上可能没有帮助。

Another option to consider which may help to reduce the number of times you experience the problem. To explain, I'll call the branch that team members' branches come from the "develop" branch.
Have a convention in your team that when the project file is modified, the changes (along with any other changes required to ensure the build integrity) are committed in a separate commit. That commit is then cherry picked onto the develop branch. Other team members who plan to modify the project file in their branch can then either cherry pick into their branch or rebase their branch on the latest develop. This approach requires communication across the team and some discipline. As I said, it won't always be possible; on some projects it might help a lot and on some projects it might not.

分開簡單 2024-10-06 06:20:31
  1. 将您的项目分解为更小、更符合逻辑的库/包。大型项目通常是糟糕设计的标志,例如对象做得太多或太大。

  2. 易于重建的设计——如果您正在编写必须由多个工具或 IDE 构建的程序,这也会有所帮助。我的许多“项目”都可以通过添加一个目录来重建。

  3. 删除无关的构建阶段。示例:我已从所有项目中删除了“复制标头”构建阶段。通过 include 指令显式包含特定文件。

  4. 尽可能使用 xcconfig 文件。这也减少了更新构建时必须进行的更改数量。 xcconfig 文件定义构建设置的集合,并支持#include。当然,当您定义要使用的 xcconfig 时,您可以从每个项目和目标中删除(大部分)用户定义的设置。

  5. 对于目标依赖项:创建执行逻辑操作而不是物理操作的目标。这通常是 shell 脚本目标或聚合目标。例如:“构建依赖项”、“运行所有单元测试”、“构建全部”、“清理全部”。那么您不必维护每一步的每个依赖项更改 - 就像使用引用一样。

  6. 为您的代码定义一个公共“源树”,为第三方源定义第二个。

  7. 有可用的外部构建工具。这可能是您的一个选择(至少对于您的某些目标而言)。

此时,一个xcodeproj就会简单很多。它将需要更少的更改,并且非常容易重建。您可以进一步了解这些概念,以进一步降低项目和构建的复杂性。

  1. Break your projects up into smaller, more logical libraries/packages. Massive projects are regularly the sign of a bad design, like the object that does way too much or is way too large.

  2. Design for easy rebuilding -- this also helps if you're writing programs which must be built by multiple tools or IDEs. Many of my 'projects' can be reconstructed by adding one directory.

  3. Remove extraneous build phases. Example: I've removed the "Copy Headers" build phase from all projects. Explicitly include the specific files via the include directive.

  4. Use xcconfig files wherever possible. This also reduces the number of changes you must make when updating your builds. xcconfig files define a collection of build settings, and support #include. Of course, you then delete the (majority of) user defined settings from each project and target when you define the xcconfig to use.

  5. For target dependencies: create targets which perform logical operations, rather than physical operations. This is usually a shell script target or aggregate target. For example: "build dependencies", "run all unit tests", "build all", "clean all". then you do not have to maintain every dependency change every step of a way - it's like using references.

  6. Define a common "Source Tree" for your code, and a second for 3rd party sources.

  7. There are external build tools available. This may be an option for you (at least, for some of your targets).

At this point, a xcodeproj will be much simpler. It will require fewer changes, and be very easy to reconstruct. You can go much further with these concepts to further reduce the complexity of your projects and builds.

余生共白头 2024-10-06 06:20:31

您可能想尝试 https://github.com/simonwagner/mergepbx/

这是一个脚本这将帮助您正确合并 Xcode 项目文件。请注意,它仍然是 alpha。

免责声明:我是 mergepbx 的作者。

You might want to try https://github.com/simonwagner/mergepbx/

It is a script that will help you to merge Xcode project files correctly. Note that it is still alpha.

Disclaimer: I am the author of mergepbx.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文