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.

라는 에러를 맞닥뜨렸다.

왜?

뷰에 설정한 constraint끼리 충돌해서 생긴 오류다.

나는 storyboard에서 constraint를 지정해줬다가 코드로 또 다시 수정을 해서 그 두개가 충돌하거나, storyboard에서 무지성으로 버튼만 누르다가 타겟 뷰가 잘못 지정돼서 오류가 났다.

어떻게 해결?

오류에서 친절히 Try this 라고 언급해준 것과 같이 내가 지정해준 constraint들을 확인 해 봤다.

오류 메시지에 어떤 뷰에 어떤 constraint를 주었는지 메모리 주소로 알려주기 때문에 보기가 어렵다. 하지만 멋진 사람들이 만들어둔 페이지를 참고하면 아주 편안하게 (그것도 시각적으로) 확인할 수 있다.

Why The Failure, Auto Layout

오류 메시지 괄호() 안에 들어 있는 내용을 그대로 복사 붙여넣기 하면 각 뷰에 어떤 constraint가 있는지 그 관계성을 그림과 함께 보여준다.

댓글남기기