英文:
project.pbxproj is always tagged as modified in git
问题
I'm having some problems with Xcode, with disappearing linked libraries, etc.
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. However, and it has been some time now, my project.pbxproj is always flagged by git as modified. I've always figured it was XCode modifying the file at the same time I was modifying some things in the GUI. However, for the first time, git is keeping me from merging, or reverting, due to changes to this file. 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. After cloning, if I just cd into the folder and git status, the file is flagged as modified.
Is this behavior normal? Have people experienced issues with this file and git? Can I revert my project.pbxproj to an older state, and is it safe to do so? Are there some git configurations that I can use to better handle this file?
My project isn't native, I'm using the react-native framework.
英文:
I'm having some problems with xcode, with disappearing linked libraries, etc.
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. However, and it has been some time now, my project.pbxproj is always flagged by git as modified. I've always figured it was XCode modifying the file at the same time I was modifying some things in the GUI. However, for the first time, git is keeping me from merging, or reverting, due to changes to this file. 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. After cloning, if I just cd into the folder and git status, the file is flagged as modified.
Is this behavior normal? Have people experienced issues with this file and git? Can i revert my project.pbxproj to an older state, and is it safe to do so? Are there some git configurations that I can use to better handle this file?
My project isn't native, I'm using the react-native framework
答案1
得分: 3
project.pbxproj
文件是不断变化的,因为它包含有关项目结构和配置、链接的框架等信息。
我发现在我的 .gitattributes
中添加 *.pbxproj binary merge=union
解决了该文件中 95% 的合并问题,总有一种罕见情况下联合合并会失败,导致关闭括号出现问题,但通常可以轻松手动找到并修复。
英文:
The file project.pbxproj
is constantly changing since it contains information about the structure and configuration of the project, linked frameworks and more.
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.
答案2
得分: 0
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. The name went from com.mycompany.MyApp to 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上更改了我的包名称,删除了一些大写字母,因为我理解包名称不应包含大写字母。名称从com.mycompany.MyApp更改为com.mycompany.myapp。结果,XCode删除了MyApp.xcodeproj文件夹并创建了一个myapp.xcodeproj文件夹(我认为这是自动化的,但不能确定,因为这发生在几个月前)。
All went well in this regard, except git kept trace of both folders in the repository. 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.
在这方面一切都进展顺利,除了git仍然在存储库中跟踪了这两个文件夹。每当我克隆我的存储库时,我都会得到一个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 always was comparing the current version of the file with one that was 2 months old. 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.
这导致git比较本地和远程的不同文件,因此系统地将此文件视为已修改,即使它只是已提交,甚至已推送。Git总是将当前版本的文件与2个月前的文件进行比较。行为不稳定,因为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? 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
人们是否遇到了与此文件和git相关的问题?是的,手动合并此文件很困难,我不建议这样做。为了避免这样做,Javier Rivarola的答案以及这个问题可能会对您有所帮助
Can i revert my project.pbxproj to an older state, and is it safe to do so? You will lose the configuration you've done after that, but the file stays valid
我可以将我的project.pbxproj还原到旧状态吗,这样做安全吗?您会失去之后所做的配置,但文件仍然有效
Are there some git configurations that I can use to better handle this file? see second question
有一些git配置可以用来更好地处理此文件吗?参见第二个问题
英文:
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. The name went from com.mycompany.MyApp to 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).
All went well in this regard, except git kept trace of both folders in the repository. 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.
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 always was comparing the current version of the file with one that was 2 months old. 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.
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? 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
Can i revert my project.pbxproj to an older state, and is it safe to do so? 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? see second question
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论