简体   繁体   English

project.pbxproj 始终在 git 中标记为已修改

[英]project.pbxproj is always tagged as modified in git

I'm having some problems with xcode, with disappearing linked libraries, etc.我在使用 xcode 时遇到了一些问题,链接库消失等。

After some research, it seems that my project.pbxproj file has been completely changed in between two commits, and I'm trying to restore an older version.经过一些研究,我的 project.pbxproj 文件似乎在两次提交之间已完全更改,我正在尝试恢复旧版本。 However, and it has been some time now, my project.pbxproj is always flagged by git as modified.但是,现在已经有一段时间了,我的 project.pbxproj 总是被 git 标记为已修改。 I've always figured it was XCode modifying the file at the same time I was modifying some things in the GUI.我一直认为是 XCode 在修改文件的同时我正在修改 GUI 中的一些内容。 However, for the first time, git is keeping me from merging, or reverting, due to changes to this file.但是,由于对此文件的更改,git 第一次阻止我合并或恢复。 I can't gitignore it as it contains vital information necessary to build my project.我不能忽略它,因为它包含构建我的项目所需的重要信息。

It gets weirder, though, as the file is indeed always in a modified state.然而,它变得更奇怪,因为文件确实总是处于修改状态。 I just tried booting my mac with absolutely no app open, no IDE, not xcode, and just opening a terminal, to clone my project in a newly created folder.我只是尝试在完全没有打开应用程序、没有 IDE、没有 xcode 的情况下启动我的 mac,只是打开一个终端,将我的项目克隆到一个新创建的文件夹中。 After cloning, if I just cd into the folder and git status, the file is flagged as modified.克隆后,如果我只是 cd 进入文件夹和 git status,该文件将被标记为已修改。

Is this behavior normal?这种行为正常吗? Have people experienced issues with this file and git?人们是否遇到过此文件和 git 的问题? Can i revert my project.pbxproj to an older state, and is it safe to do so?我可以将我的 project.pbxproj 恢复到旧状态,这样做是否安全? Are there some git configurations that I can use to better handle this file?是否有一些 git 配置可以用来更好地处理这个文件?

My project isn't native, I'm using the react-native framework我的项目不是原生的,我使用的是 react-native 框架

The file project.pbxproj is constantly changing since it contains information about the structure and configuration of the project, linked frameworks and more.文件project.pbxproj不断变化,因为它包含有关项目结构和配置、链接框架等的信息。

i found that adding *.pbxproj binary merge=union in my .gitattributes fixed 95% of my merge problems in that file, there is always one rare case where the union fails and you end up with bad closing brackets, but is usually easy to find and fix it manually.我发现在我的.gitattributes中添加*.pbxproj binary merge=union修复了该文件中 95% 的合并问题,总是有一种罕见的情况,即联合失败并且最终会出现错误的结束括号,但通常很容易手动查找并修复它。

I've understood what was my problem and I'll expose it here, then leave it to moderation to see if it is relevant, as this situation might happen to other people.我已经明白我的问题是什么,我会在这里揭露它,然后让它适度看看它是否相关,因为这种情况可能会发生在其他人身上。

I have, months ago, changed my package name on Xcode, removing some capital letters, as an application of my understanding that packages names shouldn't include capital letters.几个月前,我在 Xcode 上更改了我的包名称,删除了一些大写字母,作为我理解的应用程序,包名称不应包含大写字母。 The name went from com.mycompany.MyApp to com.mycompany.myapp.名称从 com.mycompany.MyApp 变为 com.mycompany.myapp。 As a result, XCode deleted the MyApp.xcodeproj folder and created a myapp.xcodeproj folder (I think it was automated, but can't be sure, as this happened a few months ago).结果,XCode 删除了 MyApp.xcodeproj 文件夹并创建了一个 myapp.xcodeproj 文件夹(我认为它是自动的,但不能确定,因为这发生在几个月前)。

All went well in this regard, except git kept trace of both folders in the repository.在这方面一切顺利,除了 git 跟踪存储库中的两个文件夹。 Whenever I would clone my repository, I would get a myapp.xcodeproj folder, but git would still consider there was both myapp.xcodeproj and MyApp.xcodeproj in the repository.每当我克隆我的存储库时,我都会得到一个 myapp.xcodeproj 文件夹,但 git 仍然会认为存储库中有 myapp.xcodeproj 和 MyApp.xcodeproj。

This led to git comparing different files in local and remote, therefore systematically considering this file as modified, even if it was just committed, or even pushed.这导致 git 比较本地和远程的不同文件,因此系统地认为这个文件被修改,即使它刚刚提交,甚至推送。 Git always was comparing the current version of the file with one that was 2 months old. Git 总是将文件的当前版本与 2 个月前的文件进行比较。 The behavior was erratic, as the myapp folder was always flagged as modified, and actually modifying it would flag MyApp folder as modified as well.行为不稳定,因为 myapp 文件夹总是被标记为已修改,而实际修改它也会将 MyApp 文件夹标记为已修改。

Hope this might help someone someday.希望有一天这可能会帮助某人。

I'll answer my own questions:我会回答我自己的问题:

Is this behavior normal?这种行为正常吗? Absolutely not绝对不

Have people experienced issues with this file and git?人们是否遇到过此文件和 git 的问题? Yes, human merging of this file is difficult and I wouldn't recommend it.是的,这个文件的人工合并很困难,我不推荐它。 To avoid having to do so, Javier Rivarola's answer as well as this question might help you为了避免这样做,哈维尔·里瓦罗拉 (Javier Rivarola) 的回答以及这个问题可能会对您有所帮助

Can i revert my project.pbxproj to an older state, and is it safe to do so?我可以将我的 project.pbxproj 恢复到旧状态,这样做是否安全? You will lose the configuration you've done after that, but the file stays valid您将丢失之后所做的配置,但文件保持有效

Are there some git configurations that I can use to better handle this file?是否有一些 git 配置可以用来更好地处理这个文件? see second question见第二个问题

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

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