Xcode Project file git merge conflict

前端 未结 8 1423
萌比男神i
萌比男神i 2021-01-31 03:28

In Xcode, what\'s the best way to avoid Git conflict in the project file? (I am in manual git, not using Xcode interface for git)

I\'ve cloned mapbox-ios-sdk from Github

相关标签:
8条回答
  • 2021-01-31 03:57

    When this is caused by adding files from two or more collaborators/branches (which in my experience has always been the case to date and can be checked by looking at the diff) I do this:

    1. Resolve the conflict by "use ours" or "use theirs" (whichever has added the most files).
    2. Commit (this produces a repo that contains all the added files but some are not in the project).
    3. Within Xcode use "Add Files To..." to add the missing files from the other collaborator/branch (they are easy to find as they are in the project directory and Xcode usefully highlights them for you).
    4. Commit.

    (I am not convinced step 2 is really necessary - but feels neater to me).

    0 讨论(0)
  • 2021-01-31 04:01

    In most case, you can fix the merge by following code, remove the lines which git adds:

    #!/bin/bash
    FILE={PRODUCT_NAME}.xcodeproj/project.pbxproj
    sed '/======/d' $FILE | sed '/<<<<</d' | sed '/>>>>>/d' > temp
    cat temp > $FILE
    rm temp
    

    but if you rename the group of your project and it leads to conflicts, you will manually delete the extra lines of your original group.

    0 讨论(0)
提交回复
热议问题