The value of the Xcode bitmap frame automatically causes git to merge the conflict all the time. How to solve it?

Every time I combine an iOS objc project with another team member, I have some kind of strange conflict:

<<<<<<< HEAD <rect key="frame" x="254.00000003476939" y="0.0" width="63" height="21"/> ======= <rect key="frame" x="254.00000010362709" y="0.0" width="63" height="21"/> >>>>>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 

We never change the value of x, and we always give an integer value. Obviously, Xcode automatically changed the value. How to prevent such things?

+6
source share
1 answer

You can avoid checking for such a changed value by convincing Git that the contents of the file have not changed.

This is possible with a clean script that will be responsible for storing only the integer value for x.
This script will only apply to .storyboard files (as described here ), and it will have to replace "254.xxx" with "254".

  sed -i 's/x=\"([^0-9]+).*\"/x=\"\1\"/g' 

File recovery using a script is done using a content filter filter using .gitattributes .

https://i.stack.imgur.com/tumAc.png
(image from "Configuring Git - Git Attributes" from the Pro Git book "))

Once you declare that this content driver is in the local Git configuration, it will automatically, on git commit , restore the file.
Or it will consider the file immutable on git diff / git status , even if Xcode changes that value.

See the full example in Best Practice - Git + Build Automation - Saving Configurations Separately .

+2
source

Source: https://habr.com/ru/post/977308/


All Articles