There are usually two common reasons when you have missing files in the project after a merge.
The first case is when the commit contains references of files only, but not the files themselves. That means a developer adds e.g. images to the project and commits the project file, but forgets to commit the actual image files. When you merge those changes, you get those familiar red file names that clearly state missing files. You need to get a hold of the actual files and add them to resolve the issue.
The other case is when you have to manually resolve a merge conflict in the project file. If there is a merge conflict around an addition of e.g. different image assets you’ll try to merge it manually by keeping the references of all the image assets needed. This can of course lead to errors so you might end up with missing references to actual image files. Those files exist on disk, but you removed the references while resolving merge conflicts by accident. To resolve this you just need to add the missing files to the project.
There is a case that is not common but is definitely much more difficult to detect. While adding image resources you might create a folder with the same name as someone else, or something similar that would result in the situation where you have duplicate bundle resources, but only one file actually exists on disk. Building the project would result in the error below.
ERROR: Can’t find icPlusCircle@2x.png
Command /Applications/Xcode.app/Contents/Developer/usr/bin/copypng failed with exit code 1
The trouble is the file name is of course the same since it’s a duplicate reference, and when you look at the folder structure, you clearly see that file and if you try to open it in finder you’ll get to the location of that file on disk. Everything seems to add up. You might try to clean the project, delete derived data, but nothing like that would help. To resolve this issue you have to open the Build Phases tab of your target. Look into the Copy Bundle Resources section and check to see the references of that particular file (as in the image below). As you can see the icPlusCricle has duplicates that are missing, causing the issue. Once you remove that, you’d be able to build the target. If you have multiple targets built from the same codebase you have to repeat this process for each target.
If you liked this blog post I’d appreciate if you followed me on Twitter