Is it safe to remove duplicate file links in XCprobxproj project files?

My company iPhone / ipad-product has transferred several generations of iOS and Xcode (now on 5.1 and 4.3) and has many goals. Perhaps due to these factors, there are many identical lines for each source file in the PBXBuildFile section, for example:

  14EE4CD315A5E69000DCA763 / * movie@2x.png in Resources * / = {isa = PBXBuildFile;  fileRef = 14EE4CB615A5E68500DCA763 / * movie@2x.png * /;  };
 14EE4CD415A5E69000DCA763 / * movie@2x.png in Resources * / = {isa = PBXBuildFile;  fileRef = 14EE4CB615A5E68500DCA763 / * movie@2x.png * /;  };
 14EE4CD515A5E69000DCA763 / * movie@2x.png in Resources * / = {isa = PBXBuildFile;  fileRef = 14EE4CB615A5E68500DCA763 / * movie@2x.png * /;  };
 14EE4CD615A5E69000DCA763 / * movie@2x.png in Resources * / = {isa = PBXBuildFile;  fileRef = 14EE4CB615A5E68500DCA763 / * movie@2x.png * /;  };
 14EE4CD715A5E69000DCA763 / * movie@2x.png in Resources * / = {isa = PBXBuildFile;  fileRef = 14EE4CB615A5E68500DCA763 / * movie@2x.png * /;  };

Please note that the lines for this source file are absolutely (I was wrong, they are not exactly ...) identical, and the number of repeated lines varies from one to one and a half dozen or more. Because of this duplication, the project.pbxproj PBXBuildFile section is nearly 5,000 lines long, although we really only have about 1,200 unique files.

Before I dig up a script to remove all of these duplicate lines and ask for a full regression test for all assemblies and purposes, I would be sure that Xcode does not need these duplicate lines for some secret reason.

I am sure that this was not caused by verified version control; duplicate lines appear only in the PBXBuildFile section, and although I do not like P4, we have few problems merging changes to the project.pbxproj file, although this is a little cumbersome on almost 20,000 lines. I think some release of Xcode did this, perhaps with the addition of new goals, but I did not find anyone to complain about this problem.

Secondary Questions: How did this happen? Has anyone else found these duplicate lines?

+7
source share
4 answers

Posting for posterity, in case others also come across this.

This happens all the time when developers work on separate branches and, for example, move files to different folders, add new groups to the same subfolder as another group, which another developer makes changes to a separate branch, etc., and then itโ€™s necessary merge your project changes back into a common base branch. Merging Xcode project files is their own special kind of hell, and there is no good way to determine which of these links is the one you want to keep; as @Maistor Kokir points out, the identifier will be unique for each link, and itโ€™s important that you choose the right option, since the groups refer to files by identifier and, more importantly, the assembly rules and goals also relate to the identifier.

The only way I found for a reliable fix is โ€‹โ€‹to remove all links to the corresponding file (to the assembly target "Phase Assembly" | "Compile Sources"), and then add it again.

And in order to truly fix this in the source code, I recommended that the developers make any changes to the project in the general branch. Project provisions usually do not require the same treatment; only โ€œinside the mindโ€ changes, which will include (but not ) limit) moving the file to another group or even to another place within the same group, renaming or deleting a group, deleting or changing links to a submodule, etc. Experience will be your true guidance.

+2
source

As you can see, the duplicate file ref is duplicated, but the file identifier inside each target has one slight difference 14EE4CD * 3 * 15A5E69000DCA763, the eighth digit changes.

+5
source

Finally, I wrote and ran a script to remove many duplicate file links. It seemed completely harmless, my local builds all continued to work correctly. I never checked these corrections, because then the employer replaced me, and it was rude to drop a bomb that had the potential to break assemblies for a dozen teams before leaving.

0
source

Typically, Xcode generates a unique link (ID) for files referenced by several targets. I assume that you have several build goals, and the LoginViewController refers to both, which end in different fileRef identifiers. Although it looks identical, removing them, suggesting that it can be harmless, can lead to crashes.

You can learn more about the pbxproj file from http://www.monobjc.net/xcode-project-file-format.html .

0
source

All Articles