axiom-xcode-debugging by charleswiltgen/axiom
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-xcode-debugging在调试代码之前,先检查构建环境。核心原则:80% 的“神秘”Xcode 问题都是环境问题(过期的 Derived Data、卡住的模拟器、僵尸进程),而不是代码错误。
这些是开发者实际会问的问题,本技能旨在回答:
→ 本技能会展示环境优先的诊断方法:在调查代码之前,先检查 Derived Data、模拟器状态和僵尸进程
→ 本技能会解释过期的 Derived Data 和间歇性失败,并展示 2-5 分钟的修复方法(清理 Derived Data)
→ 本技能演示 Derived Data 会缓存旧的构建,并展示如何通过删除来强制进行干净的重新构建
→ 本技能涵盖使用 simctl 进行模拟器状态诊断以及安全恢复模式(擦除/关机/重启)
→ 本技能解释 SPM 缓存问题,以及解决“幽灵”模块错误的清理 Derived Data 工作流
如果你看到任何以下情况,请怀疑是环境问题而非代码问题:
务必首先运行这些命令(在阅读代码之前):
# 1. 检查进程(有僵尸 xcodebuild 吗?)
ps aux | grep -E "xcodebuild|Simulator" | grep -v grep
# 2. 检查 Derived Data 大小(>10GB = 过期)
du -sh ~/Library/Developer/Xcode/DerivedData
# 3. 检查模拟器状态(卡在 Booting 状态?)
xcrun simctl list devices | grep -E "Booted|Booting|Shutting Down"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
如果你不知道你的方案名称:
# 列出可用方案
xcodebuild -list
# 清理所有内容
xcodebuild clean -scheme YourScheme
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf .build/ build/
# 重新构建
xcodebuild build -scheme YourScheme \
-destination 'platform=iOS Simulator,name=iPhone 16'
# 关闭所有模拟器
xcrun simctl shutdown all
# 如果 simctl 命令失败,关闭并重试
xcrun simctl shutdown all
xcrun simctl list devices
# 如果仍然卡住,擦除特定模拟器
xcrun simctl erase <device-uuid>
# 终极方案:强制退出 Simulator.app
killall -9 Simulator
# 终止所有 xcodebuild 进程(谨慎使用)
killall -9 xcodebuild
# 检查它们是否已消失
ps aux | grep xcodebuild | grep -v grep
# 隔离失败的测试
xcodebuild test -scheme YourScheme \
-destination 'platform=iOS Simulator,name=iPhone 16' \
-only-testing:YourTests/SpecificTestClass
应用修复后,在模拟器中进行验证,获取视觉确认。
# 1. 启动模拟器(如果尚未启动)
xcrun simctl boot "iPhone 16 Pro"
# 2. 构建并安装应用
xcodebuild build -scheme YourScheme \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro'
# 3. 启动应用
xcrun simctl launch booted com.your.bundleid
# 4. 等待 UI 稳定
sleep 2
# 5. 捕获截图
xcrun simctl io booted screenshot /tmp/verify-build-$(date +%s).png
快速截图:
/axiom:screenshot
完整的模拟器测试(包含导航、状态设置):
/axiom:test-simulator
在以下情况使用:
专业提示:如果你有调试深度链接(参见 axiom-deep-link-debugging 技能),可以直接导航到出问题的屏幕:
xcrun simctl openurl booted "debug://problem-screen"
sleep 1
xcrun simctl io booted screenshot /tmp/fix-verification.png
Test/build failing?
├─ BUILD FAILED with no details?
│ └─ Clean Derived Data → rebuild
├─ Build intermittent (sometimes succeeds/fails)?
│ └─ Clean Derived Data → rebuild
├─ Build succeeds but old code executes?
│ └─ Delete Derived Data → rebuild (2-5 min fix)
├─ "Unable to boot simulator"?
│ └─ xcrun simctl shutdown all → erase simulator
├─ "No such module PackageName"?
│ └─ Clean + delete Derived Data → rebuild
├─ Tests hang indefinitely?
│ └─ Check simctl list → reboot simulator
├─ Tests crash?
│ └─ Check ~/Library/Logs/DiagnosticReports/*.crash
└─ Code logic bug?
└─ Use systematic-debugging skill instead
| 错误 | 修复方法 |
|---|---|
BUILD FAILED(无详情) | 删除 Derived Data |
Unable to boot simulator | xcrun simctl erase <uuid> |
No such module | 清理 + 删除 Derived Data |
| 测试挂起 | 检查 simctl list,重启模拟器 |
| 执行旧代码 | 删除 Derived Data |
# 显示构建设置
xcodebuild -showBuildSettings -scheme YourScheme
# 列出方案/目标
xcodebuild -list
# 详细输出
xcodebuild -verbose build -scheme YourScheme
# 构建但不测试(更快)
xcodebuild build-for-testing -scheme YourScheme
xcodebuild test-without-building -scheme YourScheme
# 最近的崩溃
ls -lt ~/Library/Logs/DiagnosticReports/*.crash | head -5
# 符号化地址(如果你有 .dSYM)
atos -o YourApp.app.dSYM/Contents/Resources/DWARF/YourApp \
-arch arm64 0x<address>
❌ 在检查环境之前调试代码 — 务必先运行强制步骤
❌ 忽略模拟器状态 — “Booting” 状态可能挂起 10 分钟以上,应立即关机/重启
❌ 假设是 git 更改导致的问题 — 尽管代码已更改,Derived Data 仍会缓存旧的构建
❌ 当一个测试失败时运行完整的测试套件 — 使用 -only-testing 来隔离
之前 花 30 多分钟调试“为什么运行旧代码” 之后 2 分钟环境检查 → 清理 Derived Data → 问题解决
关键洞察 先检查环境,再调试代码。
每周安装次数
153
代码仓库
GitHub 星标数
601
首次出现
2026年1月21日
安全审计
安装于
opencode132
claude-code122
codex121
gemini-cli120
cursor114
github-copilot112
Check build environment BEFORE debugging code. Core principle 80% of "mysterious" Xcode issues are environment problems (stale Derived Data, stuck simulators, zombie processes), not code bugs.
These are real questions developers ask that this skill is designed to answer:
→ The skill shows environment-first diagnostics: check Derived Data, simulator states, and zombie processes before investigating code
→ The skill explains stale Derived Data and intermittent failures, shows the 2-5 minute fix (clean Derived Data)
→ The skill demonstrates that Derived Data caches old builds, shows how deletion forces a clean rebuild
→ The skill covers simulator state diagnosis with simctl and safe recovery patterns (erase/shutdown/reboot)
→ The skill explains SPM caching issues and the clean Derived Data workflow that resolves "phantom" module errors
If you see ANY of these, suspect environment not code:
ALWAYS run these commands FIRST (before reading code):
# 1. Check processes (zombie xcodebuild?)
ps aux | grep -E "xcodebuild|Simulator" | grep -v grep
# 2. Check Derived Data size (>10GB = stale)
du -sh ~/Library/Developer/Xcode/DerivedData
# 3. Check simulator states (stuck Booting?)
xcrun simctl list devices | grep -E "Booted|Booting|Shutting Down"
If you don't know your scheme name:
# List available schemes
xcodebuild -list
# Clean everything
xcodebuild clean -scheme YourScheme
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf .build/ build/
# Rebuild
xcodebuild build -scheme YourScheme \
-destination 'platform=iOS Simulator,name=iPhone 16'
# Shutdown all simulators
xcrun simctl shutdown all
# If simctl command fails, shutdown and retry
xcrun simctl shutdown all
xcrun simctl list devices
# If still stuck, erase specific simulator
xcrun simctl erase <device-uuid>
# Nuclear option: force-quit Simulator.app
killall -9 Simulator
# Kill all xcodebuild (use cautiously)
killall -9 xcodebuild
# Check they're gone
ps aux | grep xcodebuild | grep -v grep
# Isolate failing test
xcodebuild test -scheme YourScheme \
-destination 'platform=iOS Simulator,name=iPhone 16' \
-only-testing:YourTests/SpecificTestClass
After applying fixes, verify in simulator with visual confirmation.
# 1. Boot simulator (if not already)
xcrun simctl boot "iPhone 16 Pro"
# 2. Build and install app
xcodebuild build -scheme YourScheme \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro'
# 3. Launch app
xcrun simctl launch booted com.your.bundleid
# 4. Wait for UI to stabilize
sleep 2
# 5. Capture screenshot
xcrun simctl io booted screenshot /tmp/verify-build-$(date +%s).png
Quick screenshot :
/axiom:screenshot
Full simulator testing (with navigation, state setup):
/axiom:test-simulator
Use when:
Pro tip : If you have debug deep links (see axiom-deep-link-debugging skill), you can navigate directly to the screen that was broken:
xcrun simctl openurl booted "debug://problem-screen"
sleep 1
xcrun simctl io booted screenshot /tmp/fix-verification.png
Test/build failing?
├─ BUILD FAILED with no details?
│ └─ Clean Derived Data → rebuild
├─ Build intermittent (sometimes succeeds/fails)?
│ └─ Clean Derived Data → rebuild
├─ Build succeeds but old code executes?
│ └─ Delete Derived Data → rebuild (2-5 min fix)
├─ "Unable to boot simulator"?
│ └─ xcrun simctl shutdown all → erase simulator
├─ "No such module PackageName"?
│ └─ Clean + delete Derived Data → rebuild
├─ Tests hang indefinitely?
│ └─ Check simctl list → reboot simulator
├─ Tests crash?
│ └─ Check ~/Library/Logs/DiagnosticReports/*.crash
└─ Code logic bug?
└─ Use systematic-debugging skill instead
| Error | Fix |
|---|---|
BUILD FAILED (no details) | Delete Derived Data |
Unable to boot simulator | xcrun simctl erase <uuid> |
No such module | Clean + delete Derived Data |
| Tests hang | Check simctl list, reboot simulator |
| Stale code executing | Delete Derived Data |
# Show build settings
xcodebuild -showBuildSettings -scheme YourScheme
# List schemes/targets
xcodebuild -list
# Verbose output
xcodebuild -verbose build -scheme YourScheme
# Build without testing (faster)
xcodebuild build-for-testing -scheme YourScheme
xcodebuild test-without-building -scheme YourScheme
# Recent crashes
ls -lt ~/Library/Logs/DiagnosticReports/*.crash | head -5
# Symbolicate address (if you have .dSYM)
atos -o YourApp.app.dSYM/Contents/Resources/DWARF/YourApp \
-arch arm64 0x<address>
❌ Debugging code before checking environment — Always run mandatory steps first
❌ Ignoring simulator states — "Booting" can hang 10+ minutes, shutdown/reboot immediately
❌ Assuming git changes caused the problem — Derived Data caches old builds despite code changes
❌ Running full test suite when one test fails — Use -only-testing to isolate
Before 30+ min debugging "why is old code running" After 2 min environment check → clean Derived Data → problem solved
Key insight Check environment first, debug code second.
Weekly Installs
153
Repository
GitHub Stars
601
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode132
claude-code122
codex121
gemini-cli120
cursor114
github-copilot112
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
111,800 周安装
CodeRabbit AI代码审查工具 - 自动化代码审查、安全检测与质量分析
1,400 周安装
Brave Search API 网络搜索功能详解:快速获取结构化网页、新闻、视频搜索结果
1,400 周安装
edge-tts:基于微软Edge神经TTS的文本转语音工具,支持多语言、可调语速音高及字幕生成
1,400 周安装
TypeScript最佳实践指南:类型优先开发、函数式模式与模块结构优化
1,400 周安装
Spring Boot验证循环:构建、代码检查、测试与安全扫描完整指南
1,600 周安装
Better Icons CLI - 从200+图标库搜索获取SVG图标,支持AI代理集成
1,500 周安装