programing tip

Xcode의 디버그 콘솔 출력에서 ​​자동 레이아웃 제약 조건 오류 메시지 비활성화

itbloger 2020. 11. 26. 07:57
반응형

Xcode의 디버그 콘솔 출력에서 ​​자동 레이아웃 제약 조건 오류 메시지 비활성화


자동 레이아웃 오류 / 경고 메시지를 (일시적으로) 비활성화하는 방법이 있습니까?

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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x170098420 H:[UIView:0x15c62c100(2)]>",
    "<NSLayoutConstraint:0x170098600 UIView:0x15c6294f0.leading == UIView:0x15c628d40.leadingMargin - 8>",
    "<NSLayoutConstraint:0x170098650 H:[UIView:0x15c6294f0]-(0)-[UIView:0x15c62b750]>",
    "<NSLayoutConstraint:0x1700986a0 UIView:0x15c62b750.width == UIView:0x15c6294f0.width>",
    "<NSLayoutConstraint:0x1700986f0 UIView:0x15c628d40.trailingMargin == UIView:0x15c62b750.trailing - 8>",
    "<NSLayoutConstraint:0x170098880 H:[UIView:0x15c6294f0]-(0)-[UIView:0x15c62c100]>",
    "<NSLayoutConstraint:0x1700988d0 UIView:0x15c628d40.centerX == UIView:0x15c62c100.centerX + 1>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x170098420 H:[UIView:0x15c62c100(2)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

일부 디 컴파일을했고 실제로 방법이 있습니다.

Swift 3 용

 UserDefaults.standard.setValue(false, forKey: "_UIConstraintBasedLayoutLogUnsatisfiable")

목표 -C

[[NSUserDefaults standardUserDefaults] setValue:@(NO) forKey:@"_UIConstraintBasedLayoutLogUnsatisfiable"];

이제 "_UIConstraintBasedLayoutLogUnsatisfiable이 OFF"라는 알림 만 받게됩니다.

이 글을 읽는 모든 사람을위한 필수 알림 : 이것이 최후의 수단이되어야합니다. 제약 문제를 디버깅하고 수정하는 방법은 WWDC의 "Mysteries of Auto Layout"세션 : 파트 1파트 2를 참조하십시오 .


Swift 3.0 솔루션 :

//Hide Autolayout Warning
UserDefaults.standard.setValue(false, forKey:"_UIConstraintBasedLayoutLogUnsatisfiable")

AppKit / Cocoa로 macOS / osx를 수행하는 방법을 궁금해하는 모든 사용자

UserDefaults.standard.set(false, forKey: "NSConstraintBasedLayoutLogUnsatisfiable")
UserDefaults.standard.set(false, forKey: "__NSConstraintBasedLayoutLogUnsatisfiable")

나는 lldb를 사용하여 이것을 해결하려고 시도했고 해결책을 찾았습니다.

  1. 모듈 UIKit에서 기호 UIViewAlertForUnsatisfiableConstraints에 대한 기호 중단 점을 작성하십시오.
  2. 중단 점 작업으로 "thread return"디버거 명령을 추가합니다.
  3. 두 번째 디버거 명령 추가 : "c"
  4. "작업 평가 후 자동으로 계속"비활성화

앱에 레이아웃 문제가 발생하면 실행이 일시 중지됩니다. "thread return"명령을 사용하면 경고 메시지가 콘솔에 인쇄되기 전에 오류를 출력하는 UIViewAlertForUnsatisfiableConstraints 함수가 강제로 반환됩니다.

"c"명령을 사용하면 앱 실행이 계속됩니다 (참고 : "작업을 평가 한 후 자동으로 계속"은이 경우 어떻게 든 작동하지 않습니다).

그러나 이러한 자동 작업을 사용하면 중단 점이 두 번 맞으면 이상하게 동작 할 수 있습니다. 앱이 다운되는 행입니다. 이를 해결하기 위해 중단 점 작업을 제거하고 디버거가 프로그램 실행을 일시 중지 할 때 수동으로 명령을 입력 할 수 있습니다.

참고 URL : https://stackoverflow.com/questions/31239934/disable-autolayout-constraint-error-messages-in-debug-console-output-in-xcode

반응형