To fix it, I removed the weak keyword from the constraint definition.
@IBOutlet weak var willCrash: NSLayoutConstraint!
@IBOutlet var worksFine: NSLayoutConstraint!
XCode by default creates any @IBOutlet as weak, which means that the object is immediately deleted when there are no other objects with a strong reference to that. So when you deactivate the constraint, it probably removes some references, and because there's no strong reference to the constraint, it will free that memory. So when it's called again, it crashes.
Topic:
Developer Tools & Services
SubTopic:
General
Tags: