Deshabilitar mensajes de error de restricción de diseño automático en la salida de la consola de depuración en Xcode


¿Hay una manera de desactivar (temporalmente) los mensajes de error/advertencia de autodiagnóstico:

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.
Author: Markus Rautopuro, 2015-07-06

4 answers

Hizo algo de descompilación y en realidad hay una manera:

Para Swift 3

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

Objetivo-C

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

Ahora solo se le notificará que "_UIConstraintBasedLayoutLogUnsatisfiable está DESACTIVADO".

Recordatorio obligatorio para cualquiera que lea esto: este debería ser el último recurso, para consejos sobre la depuración y la solución de problemas de restricción, consulte las sesiones de WWDC "Misterios del diseño automático": parte 1 y parte 2.

 128
Author: Witold Skibniewski,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-31 10:30:51

Solución Swift 3.0:

//Hide Autolayout Warning
UserDefaults.standard.setValue(false, forKey:"_UIConstraintBasedLayoutLogUnsatisfiable")
 13
Author: Sourabh Sharma,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-23 14:00:32

He intentado resolver esto usando lldb y encontré una solución:

  1. Crear un Punto de interrupción Simbólico para el Símbolo UIViewAlertForUnsatisfiableConstraints en el Módulo de UIKit.
  2. Como acción de punto de interrupción agregue el comando del depurador "thread return"
  3. Agregue un segundo comando del depurador:"c"
  4. Desactivar "Automáticamente continuar después de evaluar las acciones "

Si su aplicación encuentra un problema de diseño, la ejecución se detiene. Con la instrucción " retorno de hilo", la función UIViewAlertForUnsatisfiableConstraints que imprime el error se ve obligada a regresar antes de que el mensaje de advertencia se imprima en la consola.

Con el comando " c "se continúa la ejecución de su aplicación (Nota: "Continuar automáticamente después de evaluar acciones" de alguna manera no funciona en este caso)

Sin embargo, con estas acciones automáticas, es probable que el punto de interrupción se comporte de manera extraña si se golpea dos veces seguidas, lo que causará que su aplicación se bloquee. Resolver esto permite eliminar las acciones de punto de interrupción e introducir los comandos manualmente cuando el depurador detiene la ejecución del programa.

 3
Author: Palle,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-08 04:12:44

Para cualquiera que se pregunte cómo hacer esto macOS/osx con AppKit / Cocoa

UserDefaults.standard.set(false, forKey: "NSConstraintBasedLayoutLogUnsatisfiable")
UserDefaults.standard.set(false, forKey: "__NSConstraintBasedLayoutLogUnsatisfiable")
 3
Author: Charlton Provatas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-01 19:26:43