Danny
Danny

Reputation: 4089

Xcode 8. Constraint referencing items turned off in current configuration

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.

enter image description here

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

Answers (9)

Tycho Pandelaar
Tycho Pandelaar

Reputation: 7535

Basically, make sure that you 'uninstall' all constraints for 'uninstalled' views/buttons/etc.

Upvotes: 0

chris
chris

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:

  1. If you can just reinstall the view

  2. If you want to keep the view

  3. If you can just delete the uninstalled view all together

Option 1

If you can just reinstall the view:

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

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

  1. Find every view in your view controller system that is faded out (this means it has been uninstalled)

1 enter image description here2 enter image description here

  1. Look at the constraints associated with the view

3enter image description here

  1. Uncheck "Installed"

The constraint will now also be faded (not the constraint group) as seen in the first 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 a constraint somewhere.

Option 3

If you can just delete the uninstalled view all together

  1. Delete any views that have been uninstalled which will automatically delete their constraints

  2. Clean the project (Command +Shift+K), if that doesn't work, try restarting xCode.

Upvotes: 0

Maria
Maria

Reputation: 4611

You can also find the view or constraint by looking at tag in the storyboard source.

  1. Open the storyboard as source
  2. Look for the following tag to get the id
  3. Look for the id in the storyboard to find which item it is.

Upvotes: 1

Suhaib
Suhaib

Reputation: 2061

The solution was just to delete the uninstalled views. Simple as that.

Upvotes: 0

Milan Kamilya
Milan Kamilya

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

  • Check both the items/views(first & second ) of the specific constraint whether any item is un-Install for any specific size-class. In my case the constraint was installed for all size-classes, but one of the item was installed for "wC hR" (Ref following image). enter image description here
  • Install the item to resolve the warning.
  • Now, build the app, if you still find the same warning for that specific interface/XIB file, don't worry this time some other constraints have the same problem.

Advice for Future

  • Please check whether views are properly installed while copy/paste them from other interfaces.

Upvotes: 4

Ben Thomas
Ben Thomas

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

jungledev
jungledev

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:

  • That the constraint has an id of 1ce-xx-Bx5
  • The constraint is associated with two elements:
  • One has the id of Mwb-6O-DKs
  • The other has the id of y2M-Sk-Ygh

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

AamirR
AamirR

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 :)

Installed is unchecked on a view, not on constraint itself

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

Munahil
Munahil

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

Related Questions