My company's iPhone/ipad product has migrated through several generations of iOS and Xcode (now at 5.1 and 4.3), and has many targets. Perhaps because of these factors, there are many identical lines for each source file in the PBXBuildFile section, e.g:
14EE4CD315A5E69000DCA763 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 14EE4CB615A5E68500DCA763 /* [email protected] */; }; 14EE4CD415A5E69000DCA763 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 14EE4CB615A5E68500DCA763 /* [email protected] */; }; 14EE4CD515A5E69000DCA763 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 14EE4CB615A5E68500DCA763 /* [email protected] */; }; 14EE4CD615A5E69000DCA763 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 14EE4CB615A5E68500DCA763 /* [email protected] */; }; 14EE4CD715A5E69000DCA763 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 14EE4CB615A5E68500DCA763 /* [email protected] */; };
Note that the lines for a given source file are all absolutely (I was wrong, they are not quite...) identical, and the number of duplicate lines varies from none to a half dozen or more. Because of this duplication, the project.pbxproj's PBXBuildFile section is almost 5000 lines long, though we really only have about 1200 unique files.
Before I cobble up a script to strip all these duplicate lines, and ask test for full regression on all builds and targets, I'd like to be sure that Xcode doesn't need these duplicate lines for some arcane reason.
I'm fairly certain that this wasn't caused by flubbed version control; duplicate lines only appear in the PBXBuildFile section and while I'm not fond of P4, we have little trouble merging project.pbxproj file changes, though at nearly 20,000 lines, it's a bit unwieldy. I think some release of Xcode did this, perhaps while adding new targets, but I've not found anyone else complaining about the issue.
Secondary questions: How did this happen? Has anyone else found these kind of duplicate lines?
As you see the file ref is duplicated , but the id of file inside each targets has one little difference 14EE4CD*3*15A5E69000DCA763 , the 8th digit rather varies.
Posting for posterity, in case others run into this too.
This happens all the time when developers are working on separate branches and e.g. move files around to different folders, add new groups in the same subfolder as another group that another developer makes a change to on a separate branch, etc., and then need to merge their project changes back to a common base branch. Merging Xcode project files is its own special kind of hell, and there's no good way to determine which of these references is the one you want to keep; as @Maistor Kokir points out, the id is going to be unique for each reference, and it's critical that you pick the correct one since groups refer to files by ID, and more importantly, build rules and targets also refer to the id.
The only way I've found to reliably fix this is to remove all references to the file in question (in the build target's "Build Phases" | "Compile Sources"), then add it back in again.
And, to truly fix it at the source, I've recommended that developers make any project changes on the common branch (e.g. a git "master" branch), then merge that change to their development branch. Project additions usually don't require the same treatment; only changes "within reason", which would include (but would not be limited to) moving a file to a different group, or even to a different location within the same group, renaming or removing a group, removing or modifying submodule references, etc. Experience will be your true guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With