native-app-profiling
Profile native macOS/iOS apps using Time Profiler via CLI (xctrace). Use when asked to identify performance hotspots, profile CPU usage, or diagnose slow code paths without opening Instruments.
What this skill does
# Native App Performance Profiling (CLI)
## Overview
Record Time Profiler via `xctrace`, extract samples, symbolicate, and identify hotspots without opening Instruments.
## Quick Start
### 1) Record Time Profiler
**Attach to running process:**
```bash
# Get the PID first
pgrep -x "AppName"
# Record for 90 seconds
xcrun xctrace record \
--template 'Time Profiler' \
--time-limit 90s \
--output /tmp/App.trace \
--attach <pid>
```
**Launch and record:**
```bash
xcrun xctrace record \
--template 'Time Profiler' \
--time-limit 90s \
--output /tmp/App.trace \
--launch -- /path/to/App.app/Contents/MacOS/App
```
### 2) Export Time Samples
List available schemas in the trace:
```bash
xcrun xctrace export --input /tmp/App.trace --toc
```
Export time profile data:
```bash
xcrun xctrace export \
--input /tmp/App.trace \
--xpath '/trace-toc/run/data/table[@schema="time-profile"]' \
--output /tmp/time-profile.xml
```
### 3) Get Load Address for Symbolication
While the app is running, get the `__TEXT` segment load address:
```bash
vmmap <pid> | grep "__TEXT"
```
Look for the load address (typically starts with `0x1...`).
### 4) Symbolicate Stack Frames
Use `atos` to symbolicate addresses:
```bash
atos -o /path/to/App.app/Contents/MacOS/App -l 0x100000000 <address>
```
## Workflow Notes
- **Correct binary**: Confirm you're profiling the right build (local vs /Applications)
- **Trigger the slow path**: During capture, perform the action that's slow
- **Capture duration**: If stacks are empty, capture longer or avoid idle time
- **Symbol matching**: Binary symbols must match the trace (same build)
## Available Templates
List all profiling templates:
```bash
xcrun xctrace list templates
```
Common templates:
- `Time Profiler` - CPU sampling
- `Allocations` - Memory allocations
- `Leaks` - Memory leak detection
- `System Trace` - System-level activity
- `Animation Hitches` - UI performance
## Common Commands
| Task | Command |
|------|---------|
| List templates | `xcrun xctrace list templates` |
| List devices | `xcrun xctrace list devices` |
| Record help | `xcrun xctrace help record` |
| Export help | `xcrun xctrace help export` |
| Get PID | `pgrep -x "AppName"` |
| Get load address | `vmmap <pid> \| grep __TEXT` |
| Symbolicate | `atos -o <binary> -l <load-addr> <address>` |
## Analyzing Results
### Manual Analysis
1. Export the trace to XML
2. Parse the call tree data
3. Look for frames with high sample counts
4. Focus on your app's code (filter out system frameworks)
### Identify Hotspots
Look for:
- Functions with high self-time (time spent in function itself)
- Deep call stacks indicating inefficient algorithms
- Repeated patterns suggesting optimization opportunities
## Gotchas
- **ASLR**: Runtime `__TEXT` load address changes each launch - get it from `vmmap`
- **Build mismatch**: Symbols must match the exact build that was profiled
- **Idle time**: Profiling idle app produces empty/useless data
- **Permissions**: May need to run with `sudo` for some operations
## iOS Profiling
For iOS apps on simulator:
```bash
xcrun xctrace record \
--template 'Time Profiler' \
--device <simulator-udid> \
--time-limit 60s \
--output /tmp/iOS-App.trace \
--launch -- <bundle-id>
```
Get simulator UDID:
```bash
xcrun simctl list devices | grep Booted
```
## Automation Script
Basic recording script:
```bash
#!/bin/bash
set -e
APP_NAME="$1"
DURATION="${2:-60}"
OUTPUT="${3:-/tmp/$APP_NAME.trace}"
if [ -z "$APP_NAME" ]; then
echo "Usage: $0 <app-name> [duration-seconds] [output-path]"
exit 1
fi
PID=$(pgrep -x "$APP_NAME" || true)
if [ -n "$PID" ]; then
echo "Attaching to running $APP_NAME (PID: $PID)"
xcrun xctrace record \
--template 'Time Profiler' \
--time-limit "${DURATION}s" \
--output "$OUTPUT" \
--attach "$PID"
else
echo "App not running. Please start $APP_NAME first."
exit 1
fi
echo "Trace saved to: $OUTPUT"
echo "To analyze: xcrun xctrace export --input $OUTPUT --toc"
```
## Checklist
- [ ] Correct binary path identified
- [ ] App running or launch command ready
- [ ] Slow path reproducible
- [ ] Trace recorded during problematic behavior
- [ ] Load address captured for symbolication
- [ ] Results analyzed for hotspots
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.