Are subversion conflicts in project.pbxproj normal?
If I add files to my project, and my co-worker adds f开发者_C百科iles to his project, and we both check our files in, should we expect to have conflicts? What's the best way to handle this?
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
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!
You could use FileMerge which comes with XCode. You can find it under the developer folder under Applications and then Utilities.
When you open FileMerge drag the 2 files you need to compare one into the left and one into the right. Go through and select the arrows indicating differences and choose left, right or both on the bottom right.
After you have completed this do a save as and save the file with the changes to the original file name.
精彩评论