49

I recently updated Xcode and I got the following warnings:

enter image description here

I tried Editor -> Resolve Auto-Layout Issues -> Clear all constraints in view controller but it did not work... I am using Xcode 5. How do I remove the warnings?

6 Answers 6

79

In Xcode 5 the position of views on the canvas does not update when constraints are applied. Thus, it is possible to have constraints that specify a different position for the view than you see it in Interface Builder. You can correct this by pressing Command + Option + = or selecting "Update Frames" in the |-•-| menu (I think it looks like a tie fighter).

Update for Xcode 8: The "Update Frames" command now has its own button. It's located just to the left of the Stack View / Alignment / Constraints buttons and looks like a reload arrow surrounded by corner brackets:

Update Frames

5
  • 2
    If a view has no constraints, I'm not sure what the behavior will be. You can try using "Add recommended constraints..." in the dot menu as a starting point. Sep 20, 2013 at 15:56
  • I had it only work for some of the warnings too, but the others were cleared when I rebuilt the app. Won't work all the time but worth a try.
    – Nick
    Nov 1, 2013 at 23:25
  • This just jinxes my layout, the, update constraints actually does help me get rid of the warning. Mar 25, 2015 at 9:07
  • not working for me. Event I have not applied any constraints. Getting error on xcode 9.
    – Abhishek
    Dec 22, 2017 at 5:58
  • It gets rid of the warning, but makes my button width and height not equal which is exactly what I'm trying to fix. Mar 21, 2018 at 15:28
24

Select this view in Storyboard, then 'Editor -> Resolve Auto-Layout Issues -> Update All Constraints in View'

It works for me.

4
  • Magic! Worked like a charm!
    – Lazy Ninja
    Sep 8, 2017 at 2:02
  • It adds constants from canvas to my constraints! But I just want to update position of views in canvas
    – user25
    Mar 10, 2019 at 16:42
  • 1
    So the correct option should be Editor -> Resolve Auto-Layout Issues -> Update Frames
    – user25
    Mar 10, 2019 at 16:44
  • So be careful users. It should be Update Frames. An accepted answer also mentions it stackoverflow.com/a/18920275/4548520
    – user25
    Mar 10, 2019 at 16:46
4

Xcode 8: I got this warning with 1 UICollectionView in the Storyboard and no constraints at all. Switching the "View as"-Device at the bottom to any other device and back removes the warning.

1
  • It works, but the warning comes back later… Did you find any persistent solution ? It seems to be a Xcode bug (using Xcode 9.2)
    – AnthoPak
    Apr 6, 2018 at 10:01
3

In XCode 6 the Warning is now accompanied with dimensions indicating where the view will be placed given the current constraints. If your constraints are correct (or you believe them to be) and the view (eg. a label) is not at that location, try changing the view's dimensions to the expected dimensions in the warning. If the view ends up in the right place and the warning goes away, it confirms that your constraints are working as expected.

Simply removing the constraints may remove the warning but won't necessarily give you the Auto Layout behavior you are hoping for.

1
3

In Xcode 8.1 there is now a refresh button to the far left, click your views and click that to be the equivalent of the old update frames.

enter image description here

0

To be more specific, Select your view, Go to Editor Menu -> from Resolve Auto Layout Issues select 'Clear Constraints'. This should clear your constraints and no longer give you warning when you move your components.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.