title: iOS 11: "Unable to simultaneously satisfy constraints"
body: <p>always running into the <em>FoodTracker</em> tutorial; following this step: "Implement a custom control"</p>
  
  <p><a href="https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementingACustomControl.html#//apple_ref/doc/uid/TP40015214-CH19-SW1" rel="nofollow noreferrer">https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementingACustomControl.html#//apple_ref/doc/uid/TP40015214-CH19-SW1</a></p>
  
  <p>and when executing the first checkpoint the simulator shows a red rectangle instead of a square as indicated on the tutorial; on the debug pane I get:</p>
  
  <pre><code>2018-02-09 11:19:42.130595+0100 FoodTracker[7439:80369] [MC] Lazy loading NSBundle MobileCoreServices.framework  
  2018-02-09 11:19:42.131628+0100 FoodTracker[7439:80369] [MC] Loaded MobileCoreServices.framework  
  2018-02-09 11:19:42.165143+0100 FoodTracker[7439:80369] [LayoutConstraints] Unable to simultaneously satisfy constraints.  
      Probably at least one of the constraints in the following list is one you don't want.  
      Try this:  
          (1) look at each constraint and try to figure out which you don't expect;  
          (2) find the code that added the unwanted constraint or constraints and fix it.  
  (  
      "&lt;NSLayoutConstraint:0x60400028a3c0 UIButton:0x7f8a0bd0e330.width == 44   (active)&gt;",  
      "&lt;NSLayoutConstraint:0x60400028cda0 'UISV-canvas-connection' FoodTracker.RatingControl:0x7f8a0bd08890.leading == UIButton:0x7f8a0bd0e330.leading   (active)&gt;",  
      "&lt;NSLayoutConstraint:0x60400028ce40 'UISV-canvas-connection' H:[UIButton:0x7f8a0bd0e330]-(0)-|   (active, names: '|':FoodTracker.RatingControl:0x7f8a0bd08890 )&gt;",  
      "&lt;NSLayoutConstraint:0x60400028c940 'UIView-Encapsulated-Layout-Width' FoodTracker.RatingControl:0x7f8a0bd08890.width == 200   (active)&gt;"  
  )  
  
  Will attempt to recover by breaking constraint  
  &lt;NSLayoutConstraint:0x60400028a3c0 UIButton:0x7f8a0bd0e330.width == 44   (active)&gt;  
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.  
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.  
  2018-02-09 11:19:42.165949+0100 FoodTracker[7439:80369] [LayoutConstraints] Unable to simultaneously satisfy constraints.  
      Probably at least one of the constraints in the following list is one you don't want.  
      Try this:  
          (1) look at each constraint and try to figure out which you don't expect;  
          (2) find the code that added the unwanted constraint or constraints and fix it.  
  (  
      "&lt;NSLayoutConstraint:0x60400028a370 UIButton:0x7f8a0bd0e330.height == 44   (active)&gt;",  
      "&lt;NSLayoutConstraint:0x60400028a320 'UISV-canvas-connection' FoodTracker.RatingControl:0x7f8a0bd08890.top == UIButton:0x7f8a0bd0e330.top   (active)&gt;",  
      "&lt;NSLayoutConstraint:0x60400028cf30 'UISV-canvas-connection' V:[UIButton:0x7f8a0bd0e330]-(0)-|   (active, names: '|':FoodTracker.RatingControl:0x7f8a0bd08890 )&gt;",  
      "&lt;NSLayoutConstraint:0x60400028c990 'UIView-Encapsulated-Layout-Height' FoodTracker.RatingControl:0x7f8a0bd08890.height == 110   (active)&gt;"  
  )  
  
  Will attempt to recover by breaking constraint  
  &lt;NSLayoutConstraint:0x60400028a370 UIButton:0x7f8a0bd0e330.height == 44   (active)&gt;  
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.  
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.  
  </code></pre>
  
  <p>I think that something is changed when programmatically create the button and applying custom constraints here: (I'm working with Swift and Xcode 9)</p>
  
  <pre><code>// Add constraints  
  button.translatesAutoresizingMaskIntoConstraints = false  
  button.heightAnchor.constraint(equalToConstant: 44.0).isActive = true  
  button.widthAnchor.constraint(equalToConstant: 44.0).isActive = true  
  </code></pre>
  
  <p>Any hint to solve the issue is welcome.</p>
  
  <p>Please note that I'm building a custom control... All the notes I've found googling around seems not to be applicables.</p>