Instruments Trace Viewer
Workflow
1. Export Table of Contents
bash
xctrace export --input /path/to/recording.trace --toc
The TOC XML reveals available runs, schema names, and processes.
2. Query Specific Data
Extract tables using schema names from the TOC:
bash
xctrace export --input recording.trace \ --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-sample"]' \ --output samples.xml
Common schemas: time-sample, allocation, leak, os-signpost, http-transaction
3. Symbolicate if Needed
When stack traces show addresses instead of function names:
bash
xctrace symbolicate --input recording.trace --dsym /path/to/MyApp.dSYM
dSYM locations: ~/Library/Developer/Xcode/Archives/, DerivedData/<project>/Build/Products/
Essential Commands
| Command | Purpose |
|---|---|
xctrace export --input <file> --toc | List all tables and schemas |
xctrace export --input <file> --xpath '<expr>' | Extract specific data |
xctrace export --input <file> --har --output <file>.har | Export network data as HAR |
xctrace symbolicate --input <file> --dsym <path> | Add symbol names to traces |
TOC Structure
xml
<trace-toc>
<run number="1">
<data>
<table schema="time-sample" />
<table schema="allocation" />
</data>
<processes>
<process name="MyApp" pid="12345">
<binary name="MyApp" UUID="..." />
</process>
</processes>
</run>
</trace-toc>
XPath Patterns
bash
# All data from a table --xpath '/trace-toc/run[@number="1"]/data/table[@schema="<schema>"]' # Process binaries --xpath '/trace-toc/run[@number="1"]/processes/process[@name="MyApp"]/binary' # All runs --xpath '/trace-toc/run/data/table[@schema="time-sample"]'
Template-Specific References
Consult these for detailed XPath patterns and output interpretation:
- •Time Profiler:
references/time-profiler.md - •Allocations:
references/allocations.md - •Leaks:
references/leaks.md - •SwiftUI:
references/swiftui.md - •App Launch:
references/app-launch.md - •Network:
references/network.md - •File Activity:
references/file-activity.md - •Metal System Trace:
references/metal-system-trace.md - •CPU Counters:
references/cpu-counters.md - •Signposts & Points of Interest:
references/signposts-poi.md
Troubleshooting
- •Empty output: Schema may not exist—export TOC first to verify available schemas
- •Unsymbolicated after symbolication: Verify dSYM UUID matches binary UUID with
dwarfdump --uuid MyApp.dSYM - •XPath returns nothing: Check run number exists and schema name is case-sensitive exact match