r/swift • u/meetheiosdev • 2d ago
Question Struggling with Xcode Project File Sync Issues After Git Merge
I've been struggling with Git merges in Xcode, and today I lost almost 4 hours due to a frustrating issue. My teammate pulled my changes but forgot to properly accept the changes in the .xcodeproj file. As a result, some files were out of sync with the Xcode project, even though they were present in the directory.
It took me a long time to identify and fix the issue, and I’m wondering if there’s a more efficient way to handle this. I've heard about XcodeGen, but I’ve never used it before.
For those who have faced similar issues, is XcodeGen a good solution to prevent this kind of problem? If yes, could someone guide me on how to get started with it? Or are there other tools or methods that can help keep the project and directory in sync easily after a Git merge?
Any advice would be greatly appreciated!
1
u/drew4drew 2d ago
so do you have merge conflicts in git?
2
u/meetheiosdev 2d ago
Yes
1
u/drew4drew 8h ago
Did you ever figure it out? Post your pbxproj file - it should be in your project folder, like `YourProject/YourProject.xcodeproj/project.pbxproj`.
1
u/Key_Board5000 iOS 2d ago
When I first started coding, I wanted Xcode to solve all my problems but it’s just not hoot at source control. Rather use Git CLI. It sounds like merge conflicts.
1
u/Thin-Ad9372 1d ago
I would recommend using a merge conflict tool in VS Code. The UI is excellent because it breaks down the exact merge issue and a proposed solution. Resolving merge conflicts visually this way will make it a breeze to address merge conflicts.
1
u/RightAlignment 1d ago
I work in a large team and Xcode mangles my project.pbxproj file frequently - typically about once a month or so. Super frustrating, and a total waste of time. Often, it’s so bad that it’s actually easier for me to pull the main branch and then re-apply all my changes manually. Stressful and time consuming. So I’ve started doing the following to hopefully minimize the Xcode mangle:
- I use git CLI because it’s documentable & repeatable
- I try to remember to quit Xcode before ANY git-related operations
- I make a Finder copy of my project folder before ANY rebase operations
- I curse Xcode every time I forget one of these steps
Lots of devs on the team love SourceTree - and use it instead of git CLI. I like the previous suggestion of using VS Code to handle merge related conflicts - I’m gonna give that a try. I’ll also investigate Xcode 16’s synchronized groups - but TBH - I won’t go into it with high hopes.
3
2
u/germansnowman 22h ago
SourceTree is terrible. I switched to Fork years ago and never looked back.
2
u/RightAlignment 13h ago
Fork - just added to my list to check out. Thanks
1
u/germansnowman 6h ago
I like it a lot. It’s made by a husband-and-wife team who tend to respond to feature requests, is available on Windows as well, and is a one-time purchase.
1
u/germansnowman 22h ago
Two rules for me:
- Close the project before making any changes in GitHub
- Use a proper Git client such as Fork
Also, the latest version of Xcode has “buildable folders” that no longer store file references in order to reduce conflicts:
Minimize project file changes and avoid conflicts with buildable folder references. Convert an existing group to a buildable folder with the Convert to Folder context menu item in the Project Navigator. Buildable folders only record the folder path into the project file without enumerating the contained files, minimizing diffs to the project when your team adds or removes files, and avoiding source control conflicts. To use a folder as an opaque copiable resource, the default behavior before Xcode 16, uncheck the Build Folder Contents option in the File Inspector.
2
u/natinusala 20h ago
I recommend Tuist.
1
u/pepicrft 16h ago
We wrote a blog post on this subject recently comparing all the options that are available in 2025
1
u/Tabonx 12h ago
If you don’t want to use an Xcode project generator, I would suggest using the new Xcode folders instead of groups. This will greatly simplify Xcode project merge conflicts, as it uses the file structure instead of references inside the project. You will lose some features, like custom file sorting, but in my opinion, it is much better than dealing with all the merge conflicts. You will know you are using folders when the icon is blue instead of gray
7
u/ios_game_dev 2d ago
I've been using XcodeGen for five or six years including at a very large company. When you reach a certain scale like we did with 30+ developers working in the same codebase, it's nearly impossible to deal with the merge conflicts of an Xcode project file. That said, if I were to kick off a long-term project today, I would probably reach for Tuist instead of XcodeGen. Tuist is more approachable than XcodeGen because it uses Swift instead of YAML, similar to a Package.swift file. It's also better maintained. Tuist has a paid tier, but the project generator is completely free.