If I add files to my project, and my co-worker adds files to his project, and we both check our files in, should we expect to have conflicts? What's the best way to handle this?
Yes, this is common.
I usually just resolve the conflicts by hand in a text editor; the project format isn't actually that hard to read. If the changes are small (just adding or removing a few files) you could just reappy the change through the Xcode UI if you prefer.
Yes there will be conflicts. The best way to fix this is to open the .prxproj
in a text editor like TextMate, and search for the lines with >>>
. Just remove the svn merge stuff (the lines with arrows and the line telling you which branch it came from). Then save the file and mark it as resolved. You're done!
This happens often enough to me that I have a shell script to fix these things - almost all the time merge conflicts are just because you and another person have both added new files to the project, and so you just want to keep both sides of the merge. Run this script in the main project directory (where the build and Classes directory is) any time you have a merge conflict, go to XCode to make sure it can load the merged project before you commit the fixed merge!
Note that I use this with git, you may want to check whatever merge conflict markers there are in your code use the characters below to show sections in conflict (==== is the middle divider).
mergeproj.sh
#!/bin/sh
projectfile=`find -d . -name 'project.pbxproj'`
projectdir=`echo *.xcodeproj`
projectfile="${projectdir}/project.pbxproj"
tempfile="${projectdir}/project.pbxproj.out"
savefile="${projectdir}/project.pbxproj.mergesave"
cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile
cp $projectfile $savefile
mv $tempfile $projectfile