Search code examples
iosautolayoutstoryboard

Placeholder Remove at build time constraints


Xcode Interface Builder has the checkbox "Placeholder - Remove at build time" within the Attributes Inspector of a autolayout constraint.

IB Size Inspector screenshot

I googled but could not find a satisfactory answer.

  • What is a "Placeholder" constraint?
  • What does "Remove at build time" mean?
  • Why is this useful? (An example would be helpful)

Solution

  • The "Remove at build time" option allows you to provide a Placeholder constraint for a view.

    For example, suppose you are calculating the view's height and then applying a constraint programmatically, then there might be possibility of having a compile time error in the interface builder that you haven't provided view's height constraint that was expected.

    But if you provide a placeholder height (by using 'remove at build time' option) while designing a view in the interface builder then it will not show an error and remove this placeholder constraint as soon as the interface builder builds.