151

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

Fattie
  • 30,632
  • 54
  • 336
  • 607
Zhihao Yang
  • 1,945
  • 3
  • 14
  • 26
  • @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. – Zhihao Yang Oct 27 '14 at 08:27
  • 8
    **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. – Fattie Jan 26 '17 at 12:09
  • @Fattie Please edit the accepted answer with this main reason. Thanks – Milan Kamilya Jun 20 '17 at 13:30

13 Answers13

436

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.)
Community
  • 1
  • 1
BastiBen
  • 18,671
  • 10
  • 51
  • 82
40

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.

KPM
  • 10,201
  • 3
  • 41
  • 63
  • 4
    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! – Zhihao Yang Oct 27 '14 at 09:39
  • 2
    If a view isn't marked as "Installed" in Interface Builder for its current size class, then it's deactivated. – DivideByZer0 Sep 30 '15 at 14:31
  • I have many ViewControllers in my storyboard. ¿How do I know which one has a non-installed subview? – jobima Oct 21 '15 at 08:37
  • 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. – ZaEeM ZaFaR May 16 '16 at 04:29
15

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.

Zhihao Yang
  • 1,945
  • 3
  • 14
  • 26
  • 1
    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`. – Matt Jul 22 '15 at 00:55
  • 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 May 20 '17 at 20:04
  • 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. – Andreas May 20 '17 at 20:05
8

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

Dirk
  • 844
  • 1
  • 10
  • 12
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](http://stackoverflow.com/questions/ask). You can also [add a bounty](http://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question once you have enough [reputation](http://stackoverflow.com/help/whats-reputation). - [From Review](/review/low-quality-posts/10767601) – Martin Evans Jan 04 '16 at 11:57
  • 3
    This is another way the asked question can be fixed. So just wanted to add this to help others... – Dirk Jan 05 '16 at 14:27
  • Thanks, very helpful – Ahmed Elashker Aug 22 '16 at 00:46
  • This answered narrowed down how to find and fix the issue. It worked for me! – Lance Samaria Nov 09 '17 at 04:53
6

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.

Tommie C.
  • 11,825
  • 5
  • 72
  • 92
1

One of the reasons this could happen is because you selected a size class not compatible with your constraints (wAny hAny is a common case). In such case, just select a different size class in Interface Builder and you are done.

Jano
  • 60,366
  • 20
  • 152
  • 174
1

For me, it happens if I set an object a new contraint to object (not view) with "Constraint to margins" option not ticked. Problem solved with tick the option (which is default).

Ryde
  • 493
  • 4
  • 14
1

What worked for me (and I have no idea why) is to turn "Use Trait Variations" off, then perform a clean, then turn them back on. The next build had no warnings.

To turn off "Use Trait Variations" simply select your storyboard in the Project Navigator and then select File Inspector.

enter image description here

Then just deselect "Use Trait Variations", perform clean by pressing Shift-CMD K, and then turn trait variations back on if you want to use them.

enter image description here

Scooter
  • 3,807
  • 4
  • 28
  • 44
  • 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. – Jonny Jun 15 '18 at 10:21
0

I thought it was a persisting constraint due to the other answer, however it was due to an 'outlet' I still had for an item I deleted before. What to do is:

  1. Select your ViewController
  2. Click on the 'outlet' icon on the top right
  3. Look through your outlets and carefully delete any that you don't need

Worst case scenario you delete all your outlets and just hook them up again. Case solved!

0

As mentioned and well guided in @BadCat's answer, I followed down the steps and just one more step I dared to take!

Steps to carry after last step of BadCats answer:

Step 1:

I selected the constraint in the Interface Builder and then keeping that on mind what it is it for and then deleted it.

Step 2

Build the XCode Project and it will show you may be the number of Warnings are increased. That's because you have deleted a constraint that it needs to compile well. So, go to 3rd Step!

Step 3

Re-add the constraint which you kept in mind(the one you deleted). And then re-build it again!

For Me the warnings went away just by doing this! I guess this will work out for some people!

Cause:

As I could understand the problem which caused to this warning was, I had a Label connected to an IBOutlet, but its name was starting with a capital letter. So I renamed it with a simple letter in the ViewController and came to change it in the IB. I removed past IBOutlet and went to connect it to the newly renamed property name and connected. Then I noticed there is a new warning come up.

First I tried the following answer too in this thread, but it didn't help!

Cheers!

Community
  • 1
  • 1
Randika Vishman
  • 7,157
  • 3
  • 55
  • 75
0

My case is choose label, then click control + X, it will be disable, but I don't do any thing with it. When I build, it will show warning. Solution: remove label or remove chosen control + X for label.

Duyen Hang Kim
  • 153
  • 2
  • 7
0

I delete all those UI elements including their constraints, and add them all again, those warnings just disappear. Anyway this is a worst but useful way to solve this.

Old one
  • 11
  • 3
0

I had the problem on a stack view. Deleting the constraints and re-adding them did not help. Cleaning and rebuilding did not help.

For me, the solution was to create a completely new stack view object.

Then move all elements from the old stack view into the new stack view.

Deleting the old stack view fixed the problem.

George Filippakos
  • 14,863
  • 12
  • 75
  • 86