How a new Xcode 16 feature helped my work project eliminate 66,000 lines of code

While working on large git-enabled projects in teams, merge conflicts can be the biggest nightmare and quite a challenging task, and my team is not exempt from this challenge.
The Problem
The case for Xcode projects regarding merge conflicts is quite different because the IDE relies on auto-generated pbxproj references for recognising files. More added files mean more generated file references, which could make resolving conflicts challenging. Even though you can use the built-in FileMerge macOS app to resolve them, it’s still hard to do, especially in teams, as all developers can contribute to file modifications. One mistake in the resolve conflicts process can cause a compile issue in Xcode, and you have to reset the process all over again.

The Solution
Xcode 16 has recently introduced the buildable folder feature to organise files in projects. This helps the IDE remove the need for pbxproj's auto-generated file references for recognising files. Now, the process is automatic, and changes are reflected in Xcode when files are modified through Finder.
The best part is that removing auto-generated file references means there will be no merge conflicts with this large and complex file when working in teams.

It's worth mentioning that you could create folders in older Xcode versions, but it was pointless because the IDE wouldn't recognise the files inside.
You might ask how we've usually organised files in Xcode. Well, we have had groups instead of folders, and their icon colour is grey instead of blue.

The Adoption Process
After investigating this new feature, my team decided to adopt it. Although you can right-click on the groups and choose “Convert To Folder,” it requires extra work if there are unreferenced or multiple-referenced items. In these cases, you can select "Show Details" to see the reason for the failure in the popup.

Overall, the process with our project wasn't difficult, but it was time-consuming.
The Result
This adoption helped our project find and remove over 100 unused Swift files, which contained nearly 4,000 lines of code. Regarding the pbxproj files, we couldn't completely eliminate them because some files were still required in certain groups as references. However, we managed to reduce most of its references by 62,000 lines, which was impressive.


Even though the modified pbxproj files were reduced in size, there wasn't any noticeable reduction in the binary size of the project's app target(s).
Conclusion
Xcode 16’s new buildable folders don't depend on pbxproj for recognising files, which helps teams avoid possible merge conflicts with file changes in their git branches. This feature allowed my team to find over 100 unused Swift files and eliminate a total of 66,000 lines of code. All it required was spending some hours to remove unreferenced and multi-referenced items. It also improves the team's efficiency with file and folder modifications.



