Xcode Storyboard warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration

29,726

Solution 1

This warning can be annoying and happens as of Xcode 6.1.1. The main problem is that you can not easily find the referenced constraint by clicking on the warning. I guess this is a bug and will get fixed sooner or later.

However, in the meantime you can use this little workaround:

Step 1: Detect annoying warning 😱

Annoying warning

Step 2: Right/Ctrl-Click on warning, select Reveal in Log 😨

enter image description here

Step 3: Admire the beauty of the following log snippet:

... snip ...
/Devel/MyCrippledAppNG/MyCrippledApp/Main_iPad.storyboard:Dlb-cb-nWC: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
/Devel/MyCrippledAppNG/MyCrippledApp/Main_iPad.storyboard:6Ze-mO-v5N: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
/Devel/MyCrippledAppNG/MyCrippledApp/Main_iPad.storyboard:9av-xw-u1o: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
/Devel/MyCrippledAppNG/MyCrippledApp/Main_iPad.storyboard:RPt-Uf-vaZ: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
/Devel/MyCrippledAppNG/MyCrippledApp/Main_iPad.storyboard:Rnc-4M-7jV: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
/Devel/MyCrippledAppNG/MyCrippledApp/Main_iPad.storyboard:epJ-D9-KEF: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
/Devel/MyCrippledAppNG/MyCrippledApp/Main_iPad.storyboard:4HC-Gu-01w: warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.
... snip ...

Hmmm... What's this...?

interesting

Step 4: Let's toss that into the project search bar... 😐

search

😮 Yep, you guessed right. Click it.

Step 5: 😁 OMG! Enjoy a few extra minutes of productivity until Apple fixes this annoying bug. 😎

wheeee


For 2016...

  • If you can't get it with 'Reveal in Log', show the Report Navigator. (That is the rightmost tab on the leftmost column.) Delve into the build results there. That will show the build log, including the constraint ID. courtesy buildsucceeded

enter image description here

enter image description here

  • Note that for Xcode of 5/2016, annoyingly you have to quit and restart Xcode to clear this warning in some cases.

  • Note that confusingly, the same error can be caused by an unrelated problem (this appears to be an Apple bug or poor use of error language): if you have IBInspectable items, and happen to rename them in your Swift files. Xcode does not delete the old-name UserDefinedRuntimeAttributes for you. Simply click to "Identity Inspector" (item 3 on right panel) and delete the dud items.

For 2017...

  • Yet another common, and indeed simpler, cause of the problem. If you happened to un-Install an item: As of writing, very simply Xcode does not know to automatically also uninstall any constraints which lead to that item. Quite simply, look at any un-Installed items, and for all of its constraints, just mark them un-Installed. (Or simply, perhaps just temporarily delete the un-Installed item altogether, to see if that's the problem.)

Solution 2

This message is triggered when you have deactivated a view in your storyboard, but didn't deactivate the constraints based on that view.

For example, you deactivated a button, but you still have some constraints linked to that button. It may be an intrinsic constraint like height or width, or a relative constraint like the distance from another view.

You have to turn off each of the constraints referencing the view, and you have to do it manually. Xcode is being overconservative here and won't do it for you.

Solution 3

This solution works for me.

Because I copied several items from the project I developed in Xcode 5 into Xcode 6, and the storyboard in Xcode 6 supports multiple layouts, for every constraint, I need to install it in the current configuration.

For example, I am using "Compact Width | Regular Height", for the constraint I need to set like below:

enter image description here

After I checked and set all the hundreds of constraints in my projects, clean and build, the warnings finally disappear.

Solution 4

Just wanted to add my case how this Error happened for me: In my case, I wanted to delete a Textfield with "Cmd+Backspace". I did this directly in the Scene-Builder Tree-View:

enter image description here

You can see that the snooze Field is grayed out.

So that was easily discovered for me. You can than simply really delete the Field by selecting:

Edit-Delete from the Menu

Surprisingly - this really deletes the field (including the constraints). Maybe this helps someone to easily find the cause of this annoying Warning...

Solution 5

Expanded Explanation

Nothing wrong with the other answers. I just wanted to draw attention to the wording in the original warning and to identify a couple of use-cases where this can show up in one's workflow.

constraint-warning

Constraint referencing items turned off in current configuration.

Meaning that some item (usually a control or custom view that is normally visible) referenced in one or more constraints is turned off (disabled or has the checkbox "installed" unchecked). If for example you decide that you want to move a control or view in your storyboard outside of the main view (or you may see sometimes when doing something interesting in size classes) then you may see this warning if the control has constraints attached to it.

uninstalled-control

Along with the recommended solution:

Turn off this constraint in the current configuration.

Two Approaches to Fix

Document Outline

Visually you can open the Document Outline in your storyboard and look for the grayed out Constraints that reference your control/view sitting outside of the main view (widen the outline, click the constraint, and view the attributes inspector, mouse down to review fast). Then remove the constraint from this context (size class). For example, in my case I am just holding the control until I decide later where to present it, so I chose to delete completely the offending constraint until later. But in a size class I would just uninstall the constraint from the current context using the installed checkbox in the attributes inspector.

Log Navigator/Find Tool

One can also continue to use the Log Navigator to find the problem control via the unique identifier given to each object on the storyboard. In the log it would be just before the yellow highlighted text and typically takes the form as seen in my example above: jvj-mY-DHf

Using the identifier one can then use the find tool in Xcode to locate and delete (completely) or uninstall (for the current context) the offending constraint.

log-navigator

If you're fond of Xml and its simplicity you can also just open up the Storyboard as Source Code and find the offending unique identifier and delete the appropriate block of xml.

Share:
29,726

Related videos on Youtube

Zhihao Yang
Author by

Zhihao Yang

Updated on October 08, 2021

Comments

  • Zhihao Yang
    Zhihao Yang over 2 years

    This warning happens in Xcode 6.1. Anyone have ideas what does this warning mean and what will happen with it? Many thanks!

    Below is a screenshot with the warnings opened in source code"

    enter image description here

    How to find which constraint causes the warning? Xcode does not tell you which constraint is the problem.

    enter image description here

    • Zhihao Yang
      Zhihao Yang over 9 years
      @wumm yes, the app can be successfully built and run, I am just worried that some potential issue(s) might happen somehow, which I haven't meet yet.
    • Fattie
      Fattie over 7 years
      Note that in general this issue is caused by: you have an item which is un-Installed, but, it has constraints which are still installed. In general, find the un-Installed item, and for all of its constraints, mark them un-Installed.
    • Milan Kamilya
      Milan Kamilya about 7 years
      @Fattie Please edit the accepted answer with this main reason. Thanks
  • Zhihao Yang
    Zhihao Yang over 9 years
    Thank you for your reply! Could you make it more specific what is "deactive a view"? Is it to delete a view(like a button)? but since I already deleted it, the constraint might also be deleted and could not be found? And how to "turn off constraint" in more detail, just select and delete it? Thank you very much!
  • thomasmalt
    thomasmalt over 9 years
    That explanation was amazing. Thank you!
  • 5hrp
    5hrp over 9 years
    My favorite answer of the week :) And very useful. Thanks!
  • John Doe
    John Doe about 9 years
    I just stumbled across this question, and upvoted this answer just because of how funny it was.
  • James Webster
    James Webster about 9 years
    I think emojis should be required in answers from now on.
  • Matt
    Matt almost 9 years
    Note there are also those pesky Installed checkboxes in your view object attributes. So make sure that the view objects that you think are being displayed have the correct checkbox checked. The warning is telling you that some objects are not being displayed in the current configuration.
  • bakalolo
    bakalolo almost 9 years
    What if Reveal in Log is greyed out as in my case?
  • DivideByZer0
    DivideByZer0 over 8 years
    If a view isn't marked as "Installed" in Interface Builder for its current size class, then it's deactivated.
  • jobima
    jobima over 8 years
    I have many ViewControllers in my storyboard. ¿How do I know which one has a non-installed subview?
  • Gabriel
    Gabriel over 8 years
    same thing for me the Reveal in Log is greyed out.
  • buildsucceeded
    buildsucceeded over 8 years
    If you can't get it with 'Reveal in Log', show the Report Navigator (the rightmost tab on the leftmost column) and delve into the build results there. That will show the build log, including the constraint ID.
  • jordanlgraves
    jordanlgraves over 8 years
    My Right Click -> Reveal Log was doing nothing so I opened logs using this as ref: stackoverflow.com/questions/19014359/…
  • Premal Khetani
    Premal Khetani over 8 years
    Great thanks your answer helps me a lot. Excellent answer.
  • Martin Evans
    Martin Evans over 8 years
    This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
  • Dirk
    Dirk over 8 years
    This is another way the asked question can be fixed. So just wanted to add this to help others...
  • Asad Mehmood
    Asad Mehmood over 8 years
    My friend told me about your answer.. I am here just to upvote :D Awesome :D
  • ZaEeM ZaFaR
    ZaEeM ZaFaR about 8 years
    you can right click on the warning and select the option "Source Code". There you should clearly see the hierarchy of corresponding view in respected view controller.
  • Fattie
    Fattie about 8 years
    @buildsucceeded - your tip is critical in the current version of Xcode, thanks (2016).
  • Ahmed Elashker
    Ahmed Elashker almost 8 years
    Thanks, very helpful
  • Andreas
    Andreas about 7 years
    This worked for me as well. XCode said I had 12 or 13 warnings, but looking in the log for one of them showed there was at least 100. So I went through each of them, adding a wChR for each constrain and then unchecking the generic 'Installed'. Warnings disappeared!
  • Andreas
    Andreas about 7 years
    Oh, forgot to mention. I realised about half way through that you can actually do this process for several constrains at once by selecting them at the same time.
  • Tim
    Tim almost 7 years
    Perfect answer and perfect edits. Issue STILL exists as of 2017.
  • Lance Samaria
    Lance Samaria over 6 years
    This answered narrowed down how to find and fix the issue. It worked for me!
  • Rudolf Adamkovič
    Rudolf Adamkovič over 6 years
    Great answer! Also 2018 and still not fixed.
  • BlueskyMed
    BlueskyMed about 6 years
    For 2018 Xcode 9.3.1: Report Navigator shows bland uninformative message: "Constraint referencing items turned off in current configuration." To see the actual item, you must Ctl-Click and select Expand All Transcripts
  • Jonny
    Jonny about 6 years
    I don't think this is "right" per se (constraints disappear), however this answer was helpful for me because as soon as I fiddled with this switch, and then reverted changes to last commit, Xcode would nicely update any old/incorrect/already fixed warnings of this kind. It seems that Xcode would show old, already fixed warnings actually a lot of the times - restarting Xcode normally wouldn't help for me. Flipping that switch + restore to last commit seems to show the next "real" warning of this kind; clicking on it would automatically select the problematic constraint in IB.
  • General Failure
    General Failure over 4 years
    2019, Xcode 11.2.1: turning off constraints does not remove warning