SuperAPI AI 工具集

axiom-auto-layout-debugging

测试与质量

查看项目

更新于 10-15 20:11

技能介绍

用途:该技能用于调试 Apple 平台 Auto Layout 约束问题,适用于控制台出现“Unable to simultaneously satisfy constraints”报错、视图位置错误或不显示、启动或导航时出现约束警告、布局歧义、视图尺寸异常、Debug View Hierarchy 显示错位、Storyboard/XIB 约束运行时行为不一致等场景。

主要能力:提供系统化调试流程与决策树,包括用符号断点 UIViewAlertForUnsatisfiableConstraints 在冲突发生时暂停;通过内存地址识别视图(如 po $arg1、设置 backgroundColor、recursiveDescription);用 _autolayoutTrace 查找歧义布局(Objective-C 用 po [[UIWindow keyWindow] _autolayoutTrace],Swift 用 expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]);用 constraintsAffectingLayoutForAxis: 查看某视图的约束;结合 Debug View Hierarchy 的 Show Constraints 可视化约束。还总结常见冲突模式:固定宽度与 leading/trailing 过约束、UIView-Encapsulated-Layout 冲突、autoresizingMask 未关闭、约束不足导致歧义、优先级冲突,并给出优先级策略、Content Hugging 与 Compression Resistance 用法。

使用方式:先设置符号断点,再在断点命中时用调试命令定位视图与约束,最后用视图层级调试确认。建议为约束设置 identifier、为视图设置 Label 或 accessibilityIdentifier,便于报错信息可读。程序化视图需设置 translatesAutoresizingMaskIntoConstraints = false。

限制:资料未提供该技能的安装命令、收费方式、支持平台版本或效果数据,暂未提供。内容主要面向 Xcode 与 UIKit 调试环境。