Xcode - Storyboard views size and position modified when opening
Asked Answered
S

2

22

I noticed something very annoying with Xcode: I have some storyboards for which certain views size & position are systematically updated when I open them. This is annoying especially when working with a team.

Here how I produce this behavior:

  • I pull the app from a git repository
  • Open an affected storyboard doing no modification at all
  • git diff already tells me differences like
$ git diff
...
- <rect key="frame" x="576.99999828648401" y="11" width="170" height="20"/>
+ <rect key="frame" x="577" y="11" width="170" height="20"/>
...
- <rect key="frame" x="518.99999921768904" y="7" width="228" height="30"/>
+ <rect key="frame" x="519" y="7" width="227.99999841338541" height="30"/>

Is this happening to anybody else ?

The question is:
Why is my storyboard getting modified when I'm only opening it, and how to prevent it ?


Notice:

I realized this seems to happen only on <rect /> contained into labels & textFields

Sturgis answered 21/7, 2014 at 12:56 Comment(5)
Have you been successful in solving this problem meanwhile? We are experiencing the same effects (Xcode 7.2).Jard
I don't remember having it solved. I just remember beginning to split my storyboards as much as possible to reduce the chances of merge conflict and ease its eventual resolution. (I was using Xcode 4 or 5)Sturgis
It sounds a bit carzy, but it seems to have something todo with the fact wether you are using Xcode on an external display with a different resolution. Splitting the storyboard into smaller chunks is a good idea nevertheless. ;-)Jard
Hello from 2020 and it got only crazier and more annoying. Just opening a storyboard almost guarantees to generate differences. You commit them, then you open the same storyboard again and see the slight coordinate shifts changed back again to the previous values. The "corrections" seem to depend on the device model selected on a given storyboard, i.e. whether it's a 2x or 3x retina, the changes will be either by 0.5 or by 0.333... of a pixel. Can't find a remedy. It seems like nobody at Apple uses git or something. Or nobody at Apple uses Xcode. Because it's hard not to notice this bug.Tourer
And hello from 2022. As expected from Apple.Solenne
S
1

Xcode saves the storyboard layout information in an XML file (.storyboard). So any changes on the storyboard will be reflecected in that XML. Especially if you work with teammates this information might change regularly. You can try it out by moving around some items (don't change anything else) and after that start a diff with your git repository. You should see again a change in the XML. You could ignore the storyboard file in your git checkout. But this wouldn't make much sense as your teammates may have added new items to the storyboard.

Maybe this helps as well: [Xcode changes unmodified storyboard and XIB files

If I understand the first answer correct other changes might also trigger a change on the storyboard XML file.

regards Thomas

Scrape answered 21/7, 2014 at 13:17 Comment(4)
I understand that, what I'm talking about are changes that occur when I'm doing no modification on the storyboard (simply opening it)Sturgis
I've added a link to a related discussion. Maybe that one helps.Scrape
Thank you for the link. I already saw it (I even commented the answer a month ago). My problem is a bit different and I don't have any of the OP issue actually.Sturgis
I experience the exact same issue, just opening the storyboard causes views to change positions / sizes. Extremely annoying bug in IB.Dunham
A
1

There is a bug with storyboards that nobody's looking into it seems.

Try to split the storyboards as much as possible to reduce the chances of merge conflict and ease its eventual resolution. It can also escalate if you are using Xcode on an external display with a different resolution.

This issue can only be reduced but never solved.

Achromatism answered 12/2, 2023 at 11:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.