Storyboard randomly modifying contraints - ios

Every now and then I notice my storyboard has changes ('m' beside it). I run my app and find that my views are out of position. If I check the difference between the previous and current versions of the Storybaord XML in the version editor it appears that Storyboard has made changes when I have touched nothing in the file. I have to discard these changes to get things working again. I have to admit that my layout contains warnings. It's incredibly complex (lots of views) but it works and this particularly layout only contains warnings, no errors. Has anyone else noticed this behaviour? It's incredibly annoying. I can fix it by discarding the changes but that's not exactly ideal.

I've been working with storyboard for quite some time. I've faced the issue of getting 'M' besides storyboard. What i did is set the layout constraints correctly and removed all warnings related to auto layout from storyboard but it is not necessary to remove them what i realised later. You just commit the code as you will be using git copy. Once commit is done 'M' will be gone. The reason you are getting 'M' even if you didn't touch the storyboard after you've set layout with constraints can be due to three reasons.
1.) You might be working on local copy and while creating the project you might not have unchecked the git repository.
All you need to do is uncheck while you create new project.
2.) If you are working on source of svn, then you need to commit your all the files along with your storyboard.It will remove the 'M' displaying besides your storyboard.
3.) Every time u open your storyboard the id in xml changes so due to this reason u r getting 'M' besides storyboard.

Related

XCode 8 : Weird Storyboard issue that rolls back changes each time after it is saved

I am facing a really weird storyboard issue. I am using Version 8.0 (8A218a) . For one of my projects, I have two storyboard files, one for iPhone and one for iPad.
Both storyboards are behaving insanely: I open a storyboard file and make changes to a ViewController's view, then I save. I run the application and every thing is OK.
I switch to another file then open the stoyboard file again, and it loads back the old view! (changes subviews locations, to the left after I center them, the same subviews every time).
To track down the issue :
1- I made a copy of the project, cleaned, deleted derived data. Did not solve.
2- I thought about Source Control, so I disabled Git. Did not solve.
3- Unless it is a common bug, I am out of options.
The problem is that it does this in each of my 2 storyboard files. And when I open one and fix it them switch back to the second, I find it changed!
Did anyone face this weird issue with storyboard?
Any explanation and/or suggestion to solve it please?

Storyboard corruption on file open

I am having a problem where my content is repeatedly being shifted to the right in the storyboard for multiple view controllers when I open the project. I have done nothing at this point, simply opened it. Further, undoing the modifications through git does nothing. I fix the problems and go about my day adding new features... the apps run fine in the phone and appear normal in the storyboard. However, when I open the project the next day, same thing happens and I have to fix everything again. Has anyone else experienced this issue, and what was your resolution to the problem?
I figured out what the problem was. On my first View Controller, I had some labels that had somehow become set to a width of zero. After I fixed them, and embedded them in a stack, the problem resolved itself. I have no idea how this screwed up several other view controllers; however, fingers crossed, the corruption hasn't happened again since I fixed it.
Well apparently there is just some display bug in Xcode. When I click on a new size class and click back, the elements are restored to their correct size. This was maddening, but apparently it's working fine now if I do this quick fix.

Changed found in source tree from non-changed storyboard/xib

I am using source tree to manage the version control, a strange thing happened on storyboard/xib.
Source tree detected changes in storyboard/xib files even if I only click the storyboard/xib, not even moving anything in it.
I discard the changes every time if I am not adding or moving stuff in it. But I wonder if I take the changes in the storyboard, is it OK or not? Or there is no difference?
I also wonder what is the reason this happens.
Thanks for any reply.
Edit: the changes are on the toolsVersion = "..." as well as the dependency version

Xcode storyboard discrepancies across version control

I am having quite the annoying problem with my Xcode storyboard. I have a project controlled through svn version control and everything seems to be copying over fine with the normal merges and commits. When I make a change to the storyboard and commit it, say just a dummy label, and my partner updates his project with the latest commit it shows up fine, just like it is on my own project. However, when my partner adds a dummy label and commits, my update does not show the project on the screen. It only shows the label on the scene viewer. This is also happening with tableviewcontroller's inside of other view controllers, or really anything that he updates. When the app is run the app shows everything that it is expected too, but this does not make sense as the storyboard file is not showing these things. I am not sure what is happening as nothing seemed to be wrong early on. Any help or guidance is appreciated. Here is a picture detailing what I mean.
http://imgur.com/MkJIuhC
If you would like more info about this please leave a comment!
Looks to me like you just need to update the size class when you or your partner opens up your project like so:
and choose whatever size you find appropriate for your app

I have to update frame of everything in storyboard every time I start Xcode

So each time I open my project in Xcode, I have 100's of warning because the frames of every UI Object has been moved. I have to take the time and go to each UIViewController and update frames on it.
Is there a reason this happens? How can I fix this? Any other information I need to mention?.
Do you use a repository for your code? There may be some configuration file missing, probably not comited properly
In my case, this was happening because size-class for which I have set the constraints and layout got changed when I opens the Xcode project. So make sure that the size class remain the same for which you have applied the layout or change it if it has been modified by the Xcode.
If above does not work for you, you can try having a local repository created by the Xcode and commit the code before you quit the Xcode.
Hope this helps!!
I believe this was asked previously here:
Interface Builder degrades storyboards, resizes and repositions views in small increments
I have not yet seen a fix to the problem, but the answer I posted there likely holds true here.
https://stackoverflow.com/a/28577800/682574
At least one source is due to storyboards resolving layouts to either full pixel boundaries (x=7.0, y=10.0) or partial boundaries (x=7.5, y=10.5). As best I can tell, this can be recalculated any time you view the storyboard and the rounding is actually determined based on the current display environment.
You can intentionally cause this behavior by viewing the storyboard on a retina display and then viewing it on a non-retina display. With my dual-monitor display, if I just drag a storyboard from one screen (retina 5k) to another (non-retina) it will generate a flood of misaligned constraints. Unfortunately moving it back doesn't fix them! Try it out for yourself (or don't ... it's a pain to correct).
In a team environment its easy to see how this could happen as soon as two people with different setups view the same storyboard.
How to fix it? I haven't heard of a workflow that properly corrects or avoids the problem unfortunately.
Here are a couple of reasons I've seen for intermittently misplaced views. I'm not sure if either of these is responsible for the problem you're seeing -- usually these will cause a few views to be misplaced here and there, not every view in your storyboard. But I've listed them just in case it helps.
Different team members may be using different versions of Xcode, which may position certain views slightly differently, and which will certainly change the storyboard file "tool version" and so forth.
Constraints are not usually happy with fractional widths/heights in them. This can be difficult to detect -- for example, you may have a view whose intrinsic height is an odd number of pixels vertically centered within a view whose height is an even number of pixels, causing the inner view to start at a half-pixel offset and want to be repositioned lower or higher when the storyboard is re-opened.
For xib files, you can easily write a script that updates automatically the frames:
ibtool input.xib --update-frames --write input.xib
But, you should not worry about these warnings: the frames will be automatically adjusted during the execution.
Its could happens due to having 4k external display. Everybody in my team does not have this kind of problem, only me.
After opening Xcode tries to align logical points to physical pixels, so everything moves about 0.5 point.

Resources