Constraint Layout No Longer Available

After upgrading to the latest version of Xcode, I'm no longer able to select "Constraint" from the layout dropdown in IB for the root view in a view controller. When I create a new view controller in my storyboard, the available options are "Inferred (Autoresizing Mask)" and "Autoresizing Mask" and the popup views for setting constraints are disabled.

Previously created view controllers still show "Inferred (Constraints)" and "Autoresizing Mask" as the available options.

Any ideas on how I can get back to using constraints?

Accepted Reply

I tested with Xcode 12.3.

I effectively get the exact problem you have.
And not only for top view, but for anyview included.
It occurs as well if I include a new view (e.g. label) inside an existing.

However, as soon as you create a constraint (control-drag to the safe area limit for instance), then inferred (constraints) will show.

So there is a workaround for subviews, but not for main view.
And the main view do not show the constraints relative to it anymore.

There is no problem with Xcode 12.2

There is a bug to report here specific to 12.3 (or it is a change that do need to be explained).

Replies

I'm no longer able to select "Constraint" from the layout dropdown in IB for the root view in a view controller

Sorry, but I cannot understand what you are referring to.
  • root view :

do you mean the highest level view in the view controller ?
  • layout dropdown:

I'm not sure which dropdown you refer to.
Is it the button at the bottom of the IB canvas with the small square surrounded by 4 arrows ?
Or is it in Size inspector ?

how did you access to this drop down before ?
By root view I mean the UIView that is connected to the "view" outlet in the UIViewController.
The layout dropdown is the combo box in the Size inspector labeled "Layout".

Previously there were two different options - "Constraints" (or sometimes "Inferred (Constraints)") and "Autoresizing Mask". Now the two options are "Inferred (Autoresizing Mask)" and "Autoresizing Mask" - meaning there's really only one option and I am unable to use auto layout on any new view controller in my storyboard.

Previously created view controllers still show "Inferred (Constraints)" and "Autoresizing Mask" as the available options.

Previously there were two different options

Can you clarify what you mean by previously? Using an old Xcode? Or with exactly the same Xcode some time before?

I am unable to use auto layout on any new view controller in my storyboard.

For me, adding constraints to the root view does not make sense. Can you explain what sort of constrains you were adding?
@KGraus
I tested again with Xcode 12.2
On the top view of the VC, I do see both options.

Which version of Code do you use ?
What constraint do you want to set ?
I'm currently using Xcode 12.3. I'm not sure when this behavior started, this is the first time I've added a new view controller to my storyboard since updating from Xcode 11.

I'm thinking this has to be a Xcode bug and not intentional behavior, since I can make a copy of an existing view controller and access both of those options. Only new view controllers have the problem.
I tested with Xcode 12.3.

I effectively get the exact problem you have.
And not only for top view, but for anyview included.
It occurs as well if I include a new view (e.g. label) inside an existing.

However, as soon as you create a constraint (control-drag to the safe area limit for instance), then inferred (constraints) will show.

So there is a workaround for subviews, but not for main view.
And the main view do not show the constraints relative to it anymore.

There is no problem with Xcode 12.2

There is a bug to report here specific to 12.3 (or it is a change that do need to be explained).