简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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