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?
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
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...)
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.
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
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