Reputation: 4089
I've faced with the problem after updating to Xcode 8. Every time after UI objects are deleted from the main storyboard I get the following warning:
Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
It looks like this is an Xcode bug, but anyway I want to remove these warnings from the project. I found that there were the same problem with Xcode 6 here but no answer from that question fix the problem right no. So when I find the incorrect constraint in the storyboard and delete it the amount of incorrect constrains is increasing instead of decreasing. I things that I've also tried:
Any ideas?
Upvotes: 27
Views: 7948
Reputation: 7535
Basically, make sure that you 'uninstall' all constraints for 'uninstalled' views/buttons/etc.
Upvotes: 0
Reputation: 81
To solve this problem there are a few options:
First what causes the problem? Uninstalling a view without uninstalling it's constraints.
Second why would you so this? You might want a view to remain in your view controller because you built it and then the specs changed so you wanted to remove it temporarily because perhaps that portion wasn't included in your current sprint or what have you
Last how does one solve it?
There are three options:
If you can just reinstall the view
If you want to keep the view
If you can just delete the uninstalled view all together
Option 1
If you can just reinstall the view:
Reinstall the view by toggling the installed option as seen in picture 2 on any view that is faded out as seen in picture 1
Try to clean the project(Command +Shift+K) - if that doesn't work, try a restart of xCode. If that doesn't work, you might have missed an uninstalled view somewhere.
Option 2
If you want to keep the view:
The constraint will now also be faded (not the constraint group) as seen in the first picture.
Option 3
If you can just delete the uninstalled view all together
Delete any views that have been uninstalled which will automatically delete their constraints
Clean the project (Command +Shift+K), if that doesn't work, try restarting xCode.
Upvotes: 0
Reputation: 4611
You can also find the view or constraint by looking at tag in the storyboard source.
Upvotes: 1
Reputation: 2061
The solution was just to delete the uninstalled views. Simple as that.
Upvotes: 0
Reputation: 2298
Reason
You have an item (i.e. view) which is un-Installed, but, it has constraints which are still installed. (commented by fattie)
How to find out specific constraint
It is difficult to find exact constraint which causes this warning. It mentioned step by step in BastiBen's answer how to find out the specific constraint.
Solution
Advice for Future
Upvotes: 4
Reputation: 1488
I had a view that I had uninstalled so the warning appeared. After reinstalling the view, the warning did not go away, even after a clean. But after restarting Xcode the warning went away.
Upvotes: 1
Reputation: 4345
The short answer: Inspect the source code for your storyboard for each of the ids in your warnings by searching 'id="theIdFromWarning". The ids are for the constraints. When you find the constraint id, it will reference the two element ids. Search for the elements by searching 'id="theIdForElement"' Then you'll find the name or some piece of info in that element source code to find out what element you're looking at. Then switch the storyboard back from source code to the interface builder, find the two elements, and see which size class the related constraint is installed but the element isn't. Example: ViewA.right could be horizontally constrained to ViewB.left, installed on all size classes, but ViewA might only be installed on height=Regular size class. Solution: Install ViewA on all size classes, or uninstall the constraint on all size classes and add the constraint to only the height=Regular size class.
Longer answer, step-by-step:
I was not able to easily see what constraints/elements these warnings were referring to. For me, I was able to right click the warning, and select "Reveal in log". This revealed 10 warnings in this style format:
/my/filepath/to/storyboard:1xe-xx-Bx5: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
If your log doesn't show a detailed description like this, then right-click on any log reference to Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
warning and select Expand all transcripts
, then search your log file for the constraint descriptions.
So, I opened my storyboard, right clicked the storyboard file in the project navigator and selected 'view as source code' searched for every constraint by the listed id (in the above example, I searched for the id:1xe-xx-Bx5), and found one reference to it:
<constraint firstItem="Mwb-6O-DKs" firstAttribute="top" secondItem="y2M-Sk-Ygh" secondAttribute="bottom" constant="19" id="1ce-xx-Bx5"/>
What this tells me is:
So I searched the source code for the first element by id, by searching for id="Mwb-6O-DKs"
and found this:
<label ...(truncating for readability sake)...text="Build Label"...(truncating for readability sake)...id="Mwb-6O-DKs">
This tells me that the first element is a UILabel
with the title 'Build Label'.
Searching for the second element by id, id="y2M-Sk-Ygh"
, revealed:
<viewController storyboardIdentifier="login"...(truncating for readability sake)...<layoutGuides><viewControllerLayoutGuide type="top" id="y2M-Sk-Ygh"/>
So I take this to mean that the UILabel
with the text "Build Label" has a top constraint that is turned off. (since the viewControllerLayoutGuide
constraint should never be turned off, it must be the UILabel
.
Lo and behold, it was not installed. I selected the Installed
checkbox for the UILabel, and the error disappeared.
1 down, 9 more to go! (F*ing Xcode...)
Upvotes: 12
Reputation: 12218
I was having several views that were not Installed
, after updating to xcode 8.1, I had 2 warnings.
Following steps worked for me:
1) Clean the project and restart Xcode, warnings decreased to 1.
2) Selecting the warning will show exactly which constraint having an issue. Open Attributes Inspector
and select those views where constraint is applied, look for Installed
if its unchecked on the view (not on constraint). You can either select Installed on the view, or unselect Installed on constraint itself.
See screenshot below. Installed
was unchecked on view, not on the constraint that the warning was pointing to :)
Update: Same issue again with another ViewController, a UIView was not Installed for a size class, I unselect Installed on constraint itself and warning is gone too, I guess its not an Xcode bug, its claiming to turn Installed on/off on both UIView and Constrarint
Upvotes: 28
Reputation: 2419
Show the Report Navigator
[That is the rightmost tab on the leftmost column]. This will show build log with constraint ids. For further details, look into this stackoverflow's post.
Upvotes: 4