Token导航 LogoToken导航TokenDH.com
研究检索权限需确认github未标认证来源可访问clear审计通过

axiom-auto-layout-debuggingaxiom 自动布局调试

Agent Skill

用于辅助界面设计、视觉规范、排版、配色、布局和交互体验优化。它适合让 Agent 根据产品场景整理页面结构、生成 UI 方案、检查视觉一致性或改进组件层级。使用时需要结合现有品牌、设计系统和用户任务,不应只堆装饰元素;涉及真实页面改动时,应通过截图或浏览器预览检查文本溢出、对齐和响应式表现。

总安装

4,333

周安装

177

GitHub Stars

873

下载量

1,402
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:axiom-auto-layout-debugging(axiom 自动布局调试)
来源仓库:https://github.com/charleswiltgen/axiom
仓库路径:skills/axiom-auto-layout-debugging
安装命令:
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-auto-layout-debugging
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-auto-layout-debugging

简介

辅助解决 Auto Layout 约束冲突与界面错位问题。

  • 适用于控制台报错、视图显示异常或启动时约束警告的场景。
  • 通过系统化调试工具快速定位问题,提升布局修复效率。
  • 使用时需结合项目实际约束与运行环境,避免仅依赖静态分析。
  • axiom-auto-layout-debugging 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Auto Layout Debugging

When to Use This Skill

Use when:

  • Seeing "Unable to simultaneously satisfy constraints" errors in console
  • Views positioned incorrectly or not appearing
  • Constraint warnings during app launch or navigation
  • Ambiguous layout errors
  • Views appearing at unexpected sizes
  • Debug View Hierarchy shows misaligned views
  • Storyboard/XIB constraints behaving differently at runtime

Overview

Core Principle: Auto Layout constraint errors follow predictable patterns. Systematic debugging with proper tools identifies issues in minutes instead of hours.

Time Savings: Typical constraint debugging without this workflow: 30-60 minutes. With systematic approach: 5-10 minutes.


Quick Decision Tree

Constraint error in console?
├─ Can't identify which views?
│  └─ Use Symbolic Breakpoint + Memory Address Identification
├─ Constraint conflicts shown?
│  └─ Use Constraint Priority Resolution
├─ Ambiguous layout (multiple solutions)?
│  └─ Use _autolayoutTrace to find missing constraints
└─ Views positioned incorrectly but no errors?
   └─ Use Debug View Hierarchy + Show Constraints

Understanding Constraint Error Messages

Anatomy of Error Message

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list you don't need.

(
    "<NSLayoutConstraint:0x7f8b9c6...  'UIView-Encapsulated-Layout-Width' ... (active)>",
    "<NSLayoutConstraint:0x7f8b9c5...  UILabel:0x7f8b9c4... .width == 300   (active)>",
    "<NSLayoutConstraint:0x7f8b9c3...  UILabel:0x7f8b9c4... .leading == ... + 20   (active)>",
    "<NSLayoutConstraint:0x7f8b9c2...  ... .trailing == UILabel:0x7f8b9c4... .trailing + 20   (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f8b9c5... UILabel:0x7f8b9c4... .width == 300   (active)>

Key Components:

  1. Memory addresses0x7f8b9c4... identifies views and constraints
  2. Visual Format — Human-readable constraint description
  3. (active) status — Constraint is currently enforced
  4. Recovery action — Which constraint system will break (usually lowest priority)

System-Generated Constraints

UIView-Encapsulated-Layout-Width/Height:

  • Created by UIKit for cells, system views
  • Often source of conflicts
  • Usually correct; your constraints are the problem

Autoresizing Mask Constraints:

  • Format: h=--& or v=&--
  • - = fixed dimension
  • & = flexible dimension
  • Example: h=--& = fixed left margin and width, flexible right margin

Debugging Workflow

Step 1: Set Up Symbolic Breakpoint (One-Time Setup)

Purpose: Break when constraint conflict occurs, before system breaks constraint.

Setup:

  1. Open Breakpoint Navigator (⌘+7 or ⌘+8)
  2. Click + → "Symbolic Breakpoint"
  3. Symbol: UIViewAlertForUnsatisfiableConstraints
  4. (Optional) Add Action → "Sound" → select sound
  5. (Optional) Check "Automatically continue after evaluating actions"

Why this works: Pauses execution at exact moment of constraint conflict, giving you debugger access to all views and constraints.


Step 2: Identify Views from Memory Addresses

When breakpoint hits, console shows memory addresses like UILabel:0x7f8b9c4...

Technique 1: Use %rbx Register (When Breakpoint Hits)

# Print all involved views and constraints
po $arg1

# Or on older Xcode versions
po $rbx

Output: NSArray containing all conflicting constraints and affected views.

Technique 2: Set View Background Color

# Set background color on suspected view
expr ((UIView *)0x7f8b9c4...).backgroundColor = [UIColor redColor]

# Continue execution to see which view turned red

Result: Visually identifies which view corresponds to memory address.

Technique 3: Print View Hierarchy

Objective-C projects:

po [[UIWindow keyWindow] _autolayoutTrace]

Swift projects:

expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]

Output: Entire view hierarchy with * marking ambiguous layouts.

Example:

*<UIView:0x7f8b9c4...>
|   <UILabel:0x7f8b9c3...>

The * indicates this UIView has ambiguous constraints.

Technique 4: Print Constraints for Specific View

# Horizontal constraints (axis: 0)
po [0x7f8b9c4... constraintsAffectingLayoutForAxis:0]

# Vertical constraints (axis: 1)
po [0x7f8b9c4... constraintsAffectingLayoutForAxis:1]

Output: All constraints affecting that view's layout.


Step 3: Use Debug View Hierarchy

When to use: Views positioned incorrectly, constraints not visible in code.

Workflow:

  1. Trigger the issue — Navigate to screen with constraint problems
  2. Pause execution — Click "Debug View Hierarchy" button in debug bar (or Debug → View Debugging → Capture View Hierarchy)
  3. Inspect 3D view — Rotate view hierarchy to see layering
  4. Enable "Show Constraints" — Shows all constraints as lines
  5. Select view — Right panel shows all constraints affecting selected view

Key Features:

  • Show Clipped Content — Reveals views positioned off-screen
  • Show Constraints — Visualizes constraint relationships
  • Filter Bar — Search for specific views by class or memory address

Finding Issues:

  • Purple constraints = satisfied
  • Orange/red constraints = conflicts
  • Select constraint → see both views it connects

Step 4: Name Your Constraints (Prevention)

Why: Makes error messages readable instead of cryptic memory addresses.

In Interface Builder (Storyboards/XIBs)

  1. Select constraint in Document Outline
  2. Open Attributes Inspector
  3. Set Identifier field (e.g., "ProfileImageWidthConstraint")

Before:

<NSLayoutConstraint:0x7f8b9c5... UILabel:0x7f8b9c4... .width == 300   (active)>

After:

<NSLayoutConstraint:0x7f8b9c5... 'ProfileImageWidthConstraint' UILabel:0x7f8b9c4... .width == 300   (active)>

Programmatically

let widthConstraint = imageView.widthAnchor.constraint(equalToConstant: 100)
widthConstraint.identifier = "ProfileImageWidthConstraint"
widthConstraint.isActive = true

Impact: Instantly know which constraint is breaking without hunting through code.


Step 5: Name Your Views (Prevention)

Why: Error messages show view class AND your custom label.

In Interface Builder

  1. Select view in Document Outline
  2. Open Identity Inspector
  3. Set Label field (e.g., "Profile Image View")

Before:

<UIImageView:0x7f8b9c4... (active)>

After:

<UIImageView:0x7f8b9c4... 'Profile Image View' (active)>

Programmatically

imageView.accessibilityIdentifier = "ProfileImageView"

Note: Xcode automatically uses textual components (UILabel text, UIButton titles) as identifiers when available.


Common Constraint Conflict Patterns

Pattern 1: Conflicting Fixed Widths

Symptom:

Container width: 375
Child width: 300
Child leading: 20
Child trailing: 20
// 20 + 300 + 20 = 340 ≠ 375

❌ WRONG:

// Conflicting constraints
imageView.widthAnchor.constraint(equalToConstant: 300).isActive = true
imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true
imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true
// Over-constrained: width + leading + trailing = 3 horizontal constraints (only need 2)

✅ CORRECT Option 1 (Remove fixed width):

// Let width be calculated from leading + trailing
imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true
imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true
// Width will be container width - 40

✅ CORRECT Option 2 (Use priorities):

let widthConstraint = imageView.widthAnchor.constraint(equalToConstant: 300)
widthConstraint.priority = .defaultHigh // 750 (can be broken if needed)
widthConstraint.isActive = true

imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true
imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true
// Required constraints (1000) will break lower-priority width constraint if needed

Pattern 2: UIView-Encapsulated-Layout Conflicts

Symptom: Table cells or collection view cells conflicting with UIView-Encapsulated-Layout-Width.

Why it happens: System sets cell width based on table/collection view. Your constraints fight it.

❌ WRONG:

// In UITableViewCell
contentLabel.widthAnchor.constraint(equalToConstant: 320).isActive = true
// Conflicts with system-determined cell width

✅ CORRECT:

// Use relative constraints, not fixed widths
contentLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16).isActive = true
contentLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16).isActive = true
// Width adapts to cell width automatically

Pattern 3: Autoresizing Mask Conflicts

Symptom: Mixing Auto Layout with autoresizingMask or not setting translatesAutoresizingMaskIntoConstraints = false.

❌ WRONG:

let imageView = UIImageView()
view.addSubview(imageView)

// Forgot to disable autoresizing mask
imageView.widthAnchor.constraint(equalToConstant: 100).isActive = true
// Conflicts with autoresizing mask constraints

✅ CORRECT:

let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false // ← CRITICAL
view.addSubview(imageView)

imageView.widthAnchor.constraint(equalToConstant: 100).isActive = true

Why: translatesAutoresizingMaskIntoConstraints = true creates automatic constraints that conflict with your explicit constraints.


Pattern 4: Ambiguous Layout (Missing Constraints)

Symptom: View appears, but position shifts unexpectedly or _autolayoutTrace shows * (ambiguous).

Problem: Not enough constraints to determine unique position/size.

❌ WRONG (Ambiguous X position):

imageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 20).isActive = true
imageView.widthAnchor.constraint(equalToConstant: 100).isActive = true
imageView.heightAnchor.constraint(equalToConstant: 100).isActive = true
// Missing: horizontal position (leading/trailing/centerX)

✅ CORRECT:

imageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 20).isActive = true
imageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true // ← Added
imageView.widthAnchor.constraint(equalToConstant: 100).isActive = true
imageView.heightAnchor.constraint(equalToConstant: 100).isActive = true

Rule: Every view needs:

  • Horizontal: 2 constraints (e.g., leading + width, OR leading + trailing, OR centerX + width)
  • Vertical: 2 constraints (e.g., top + height, OR top + bottom, OR centerY + height)

Pattern 5: Priority Conflicts

Symptom: Unexpected constraint breaks, but all constraints seem correct.

Problem: Multiple constraints at same priority competing.

❌ WRONG:

// Both required (priority 1000)
imageView.widthAnchor.constraint(equalToConstant: 100).isActive = true
imageView.widthAnchor.constraint(greaterThanOrEqualToConstant: 150).isActive = true
// Impossible: width can't be 100 AND >= 150

✅ CORRECT:

let preferredWidth = imageView.widthAnchor.constraint(equalToConstant: 100)
preferredWidth.priority = .defaultHigh // 750
preferredWidth.isActive = true

let minWidth = imageView.widthAnchor.constraint(greaterThanOrEqualToConstant: 150)
minWidth.priority = .required // 1000
minWidth.isActive = true

// Result: width will be 150 (required constraint wins)

Priority levels (higher = stronger):

  • .required (1000) — Must be satisfied
  • .defaultHigh (750) — Strong preference
  • .defaultLow (250) — Weak preference
  • Custom: any value 1-999

Debugging Checklist

Before Debugging

  • Read full error message in console (don't ignore it)
  • Note which constraints are listed as conflicting
  • Check if error is consistent or intermittent

During Debugging

  • Set symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints
  • Identify views using memory addresses (background color technique)
  • Use Debug View Hierarchy to visualize constraints
  • Check _autolayoutTrace for ambiguous layouts
  • Verify translatesAutoresizingMaskIntoConstraints = false for programmatic views

After Fixing

  • Test on multiple device sizes (iPhone SE, iPhone Pro Max)
  • Test orientation changes (portrait/landscape)
  • Test with Dynamic Type sizes
  • Verify no console warnings during transitions
  • Add constraint identifiers for future debugging

Advanced Techniques

Constraint Priority Strategy

Use case: View that should be certain size, but can shrink if needed.

// Preferred size: 200x200
let widthConstraint = imageView.widthAnchor.constraint(equalToConstant: 200)
widthConstraint.priority = .defaultHigh // 750
widthConstraint.isActive = true

let heightConstraint = imageView.heightAnchor.constraint(equalToConstant: 200)
heightConstraint.priority = .defaultHigh // 750
heightConstraint.isActive = true

// But never smaller than 100x100
imageView.widthAnchor.constraint(greaterThanOrEqualToConstant: 100).isActive = true
imageView.heightAnchor.constraint(greaterThanOrEqualToConstant: 100).isActive = true

// And never larger than container
imageView.widthAnchor.constraint(lessThanOrEqualTo: containerView.widthAnchor).isActive = true
imageView.heightAnchor.constraint(lessThanOrEqualTo: containerView.heightAnchor).isActive = true

Result: Image is 200x200 when space available, shrinks to fit container (min 100x100).


Content Hugging and Compression Resistance

Content Hugging (resist expanding):

// Label should not stretch beyond its text width
label.setContentHuggingPriority(.defaultHigh, for: .horizontal)

Compression Resistance (resist shrinking):

// Label should not truncate if possible
label.setContentCompressionResistancePriority(.required, for: .horizontal)

Common pattern:

// In horizontal stack: priorityLabel (hugs) + spacer + valueLabel (hugs)
priorityLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal)
valueLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal)

// Spacer fills remaining space (low hugging priority)
spacerView.setContentHuggingPriority(.defaultLow, for: .horizontal)

Debugging Transformed Views

Problem: View transformations (rotate, scale) don't affect Auto Layout.

Gotcha:

imageView.transform = CGAffineTransform(rotationAngle: .pi / 4) // 45° rotation
// Auto Layout still uses original (un-rotated) frame for calculations

Solution: Auto Layout works correctly, but visual debugging can be confusing. Use original frame for constraint debugging.


Troubleshooting

Issue: Breakpoint Never Hits

Check:

  1. Symbolic breakpoint symbol is exactly UIViewAlertForUnsatisfiableConstraints
  2. Breakpoint is enabled (checkmark visible)
  3. Constraint conflict actually exists (check console for error message)

Issue: Can't Identify View from Memory Address

Solution 1: Use background color technique

expr ((UIView *)0x7f8b9c4...).backgroundColor = [UIColor redColor]
continue

Solution 2: Print recursive description

po [0x7f8b9c4... recursiveDescription]

Solution 3: Check view's class

po [0x7f8b9c4... class]

Issue: Debug View Hierarchy Shows No Constraints

Check:

  1. Click "Show Constraints" button in debug bar (looks like constraint icon)
  2. Select specific view to see its constraints in right panel
  3. Constraints may be satisfied (purple) vs conflicting (orange/red)

Issue: Constraints Change at Runtime

Check:

  1. UIKit system constraints (UIView-Encapsulated-Layout) added for cells/system views
  2. Dynamic Type changes (font size changes = size invalidation)
  3. Orientation changes triggering new constraints
  4. View controller lifecycle (viewDidLoad vs viewWillLayoutSubviews)

Common Mistakes

❌ Ignoring Console Warnings

Wrong: Seeing constraint warning, continuing anyway.

Correct: Fix every constraint warning immediately. They compound and cause unpredictable layout later.


❌ Not Setting Identifiers

Wrong: Debugging constraints by memory address.

Correct: Always set constraint identifiers. 30 seconds now saves 30 minutes later.


❌ Over-Constraining

Wrong: Setting leading + trailing + width.

Correct: Use 2 of 3 (leading + trailing, OR leading + width, OR trailing + width).


❌ Mixing Auto Layout and Frames

Wrong:

imageView.frame = CGRect(x: 50, y: 50, width: 100, height: 100) // Manual frame
imageView.widthAnchor.constraint(equalToConstant: 100).isActive = true // Auto Layout

Correct: Choose one approach. If using Auto Layout, set translatesAutoresizingMaskIntoConstraints = false and let constraints determine position/size.


Real-World Impact

Before (no systematic approach):

  • 30-60 minutes per constraint conflict
  • Trial-and-error constraint changes
  • Frustration from cryptic error messages
  • Breaking working constraints to fix new ones

After (systematic debugging):

  • 5-10 minutes per constraint conflict
  • Targeted fixes with Debug View Hierarchy
  • Named constraints = instant identification
  • Symbolic breakpoint catches issues immediately

Related Skills

  • For Xcode environment issues: See axiom-xcode-debugging skill
  • For SwiftUI layout issues: See axiom-swiftui-performance skill
  • For testing UI: See axiom-ui-testing skill

Resources

Docs: /library/archive/documentation/userexperience/conceptual/autolayoutpg/debuggingtricksandtips


Key Takeaways

  1. Name everything — Constraints and views with identifiers save hours of debugging
  2. Use symbolic breakpoint — Catch constraint conflicts at source, not after recovery
  3. Debug View Hierarchy — Visualize constraints instead of guessing
  4. Memory address → View — Background color technique instantly identifies mystery views
  5. Two constraints per axis — Avoid over-constraining (leading + trailing + width = conflict)
  6. Priorities matter — Use.required (1000) for must-haves,.defaultHigh (750) for preferences
  7. Systematic wins — Following workflow saves 30-50 minutes per conflict

Last Updated: 2024 Minimum Requirements: Xcode 12+, iOS 11+ (symbolic breakpoints work on all versions)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

31.48%
按下载量换算441

Codex

21.11%
按下载量换算296

OpenCode

18.87%
按下载量换算265

Antigravity

13.7%
按下载量换算192

Cursor

8.14%
按下载量换算114

Gemini CLI

3.81%
按下载量换算53

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

权限需确认

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills