Every time when I merge other team member's iOS objc project, I got some strange conflict like this:
<<<<<<< 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 integer like value. Obviously, Xcode changed the value automatically. How to prevent this kind things happen?
You could avoid checking in such modified value by convincing Git that the file content has not changed.
That is possible with a clean
script which will be in charge of keeping only an integer value for x.
That script will be applied only to the .storyboard
files (as described here), and will have to replace "254.xxx" by "254".
sed -i 's/x=\"([0-9]+).*\"/x=\"\1\"/g'
The restoration of the file through that script is automated through a content filter driver, using a .gitattributes
declaration.
(image from "Customizing Git - Git Attributes" from "Pro Git book"))
Once you declare that content filer driver in your local git config, it will automatically, on git commit
, restore the file.
Or it will consider the file as unchanged on git diff
/git status
, even when XCode modified that value.
See a complete example in "Best practice - Git + Build automation - Keeping configs separate".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With