Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do internal inconsistencies occur in Main.storyboard and how do I get around it?

I open a project from XCode 8 on Sierra macOS, which was working on yesterday with no problems.
Now I see:

The document "Main.storyboard" had 2 internal inconsistencies that were found and repaired. This may be due to an SCM operation such as merging. Please save the document to fix the inconsistencies.

storyboard errors

I cannot click either of those buttons. They don't respond. I cannot do anything except close the project. What should I do now to fix this?

Does anyone know reasons that this occurs?

like image 766
raddevus Avatar asked Nov 02 '16 00:11

raddevus


2 Answers

I cannot believe I found the answer...well, got to a solution on this terrible thing that seems to be caused by XCode's interaction with the built-in Source Control.

I had to close XCode a number of times to finally get to this. I was hacking the main.storyboard file using a text editor. I tried all kinds of things.

Finally, I thought about the error message more.

What was "SCM" in that original message? I guessed it was Source Control Module because it mentioned merging.

I then noticed that the capital "M" next to my main.storyboard file on the left where the project files are listed. It looks like:

project files modified

I guessed that was showing me that Source Control was saying it was "M"odified so I right-clicked on the main.storyboard file and told it to discard changes.

It looks like the following:

roll back changes

After that, I was able to open the storyboard again. The odd thing is that at one point I was even able to run the project while it was in the corrupted state.
Took a lot of finagling to get it done.

The XCode Devs have to fix this. It's terrible.

EDIT 2 Ugh! What a waste of time. Every time I go to view the storyboard again, then the SCM merges something in and finally i do see something that has to do with the error. it looks like: large stack view

oh, sure, it's probably something I've done with the InterfaceBuilder and it's my fault and all, but the terrible horrible stupid XCode has let me do it.

Edit 3 Okay, I noticed that it believes the label is all stretched out. But, it's the source control merge thing that is automatically doing this. I wonder if my entire project is going to be toast? label has huge height

Edit 4

I was able to get further through this problem with a few more details so I wanted to document them to help others.

Part of the Root Cause

The issue was that for some unknown reason a specific label when placed inside a stackview would go bonkers and attempt to be 9,000,0000,000 units in height.

One Way To Fix

Take a quick look at the 2nd image in this post. It shows where I right-click on the main.storyboard file. I actually saw the label go crazy again with the huge height when Interface Builder attempted to render the storyboard and then I was able to

  1. choose Open With External Editor
  2. Search for the offending size (I searched for 9,000,000)
  3. alter the size in the file and save and then Interface builder re-renders properly.

Conflicting Constraints

I also found a number of conflicting constraints which were questionable and I got all of those settled. After that, I did still see the label go crazy if I copied it into the StackView but at least I could alter it via editing it in the text editor. Good luck.

like image 67
raddevus Avatar answered Oct 21 '22 23:10

raddevus


I had this same issue (5 internal inconsistencies), and found a solution similar to @daylight, but thought I could add more color.

First - useful to highlight how debilitating this was - I could not close the dialog, and thus could not change anything in the storyboard to fix it - horrible bug.

The problem:

  • on Xcode 8, Xcode was silently changing the storyboard massively (can track the changes via git). Some of these changes added ridiculous heights to labels in stackviews (as per @daylight). Presumably xCode was trying + failing to resolve layout conflicts automatically. These changes were causing / associated with the dialog in this question, which causes a crash.

  • Once xcode adds these changes, the only way to access the file is by opening as source.

  • The very first time Xcode 8 opens the storyboard + right after it asks for you to choose a viewing device, I was able to access the the storyboard graphically, which gave me an opportunity to inspect it.

  • I was not able to fix problems by simply discarding / fixing changes, as Xcode would then make them again.

Solution:

  • By carefully tracking + reverting changes made via git, and looking for crazy high height numbers, I was able to trace the problems to stackviews in one view. I took all my content out of those stackviews (in that brief opportunity when I could access the storyboard graphically) + deleted them. Problem solved. Now I just need to reformat that view, which in my case is not too much work.
like image 28
Phil_Ken_Sebben Avatar answered Oct 21 '22 23:10

Phil_Ken_Sebben