Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

docs: guide to tracing iPhone crashes in PostHog

leepokaid18c4905243d
diff --git a/docs/README.md b/docs/README.md
index 3bfa459b..29ee868a 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -23,7 +23,7 @@ Source review, a passing build, local integration tests and production acceptanc
| Set up accounts, approvals or desktop SSH | [Accounts and SSH](guides/accounts-and-ssh.md) |
| Check connectors against live services | [Connector verification](guides/connector-verification.md) |
| Change transport or cryptography | [Remote protocol](reference/remote-relay.md) and [shared vectors](reference/fixtures/README.md) |
-| Look into errors or failed turns users hit | [Usage analytics](features/analytics.md), [investigations](#investigations) |
+| Look into errors or failed turns users hit | [Usage analytics](features/analytics.md), [iPhone crash tracing](guides/iphone-crash-tracing.md), [investigations](#investigations) |
## Features
diff --git a/docs/features/analytics.md b/docs/features/analytics.md
index 6b9b1f29..ac01a7bb 100644
--- a/docs/features/analytics.md
+++ b/docs/features/analytics.md
@@ -95,7 +95,8 @@ builds PostHog frames itself (oldest first, the failing one last): generic `cust
address). PostHog symbolicates them with the release's dSYMs, which the *iOS dSYMs* workflow
uploads from its Xcode Cloud archive after *Submit iOS* (`tools/upload-dsyms.py`, secret
`POSTHOG_CLI_API_KEY`: a personal API key with *error tracking write* on this project). A frame
- it can't resolve, such as the system's, shows `binary + offset`. Process `ios`.
+ it can't resolve, such as the system's, shows `binary + offset`. Process `ios`. Reading one,
+ older versions and fixes: [iPhone crash tracing](../guides/iphone-crash-tracing.md).
- **Android** (`CrashReports.kt`): an uncaught exception is written down as it happens and sent
on the next launch: its type and frames (class, method, file name, line), never the message.
Process `android`.
diff --git a/docs/guides/development.md b/docs/guides/development.md
index 8eca6096..7b50757d 100644
--- a/docs/guides/development.md
+++ b/docs/guides/development.md
@@ -126,4 +126,4 @@ To bump, set `version` in `host/crates/memory/Cargo.toml` (patch for fixes, mino
## iOS releases (Xcode Cloud)
-The Xcode Cloud workflow "Release" on the product "iOS" has no automatic start condition (its own tag trigger never fired); it only runs when started through the API, and it archives the `iOS` scheme in Release with deployment preparation **TestFlight and App Store** (the "Internal Testing Only" option produces builds App Review can't take) and uploads it to App Store Connect. Xcode Cloud overrides the build number with its own counter (`CI_BUILD_NUMBER`, configured under Xcode Cloud settings → Build Number in App Store Connect), so `CURRENT_PROJECT_VERSION` in `project.yml` is only the local default. The checked-in `apps/Codync.xcodeproj` is what the cloud builds: regenerate it whenever `project.yml` changes, and commit `apps/Codync.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved` whenever a package version changes (Xcode Cloud never resolves packages itself; copy `apps/ios/Kit/Package.resolved` there if Xcode wrote it to `apps/ios/Kit/`). Xcode Cloud reads public package repositories without any connection. The `Submit iOS` GitHub workflow (`.github/workflows/ios-submit.yml` → `tools/asc-submit.py`, secrets `ASC_KEY_ID`, `ASC_ISSUER_ID`, `ASC_PRIVATE_KEY`) runs on every `v*` tag (the tags Auto Tag pushes after a version bump on `main`). It compares the tag with the last version sent to the App Store: when nothing the iPhone app is built from changed (`apps/ios/` including `apps/ios/Kit/`, `apps/shared/`, the package pins, or `apps/project.yml` beyond its version lines), iOS skips that release, so host- or desktop-only releases neither build nor touch a version in review. Otherwise it starts the Xcode Cloud archive on the tag, waits for that build to finish processing and submits it for App Review, released automatically after approval. The latest version wins: a version still *Waiting for Review* is pulled back, renamed and resubmitted with the new build; one already *In Review* or approved is left alone (rerun the workflow with the version once it is out). *What's New* comes from the version's `## <version>` section in `apps/ios/WhatsNew.md` (one `### <locale>` per App Store language, written in the version bump); without one, the `### zh-Hant` / `### en-US` bullets under `## What's New` in the PR template are collected from every PR merged since the last App Store version (changes pushed to `main` without a PR add nothing); with neither, empty fields get a generic "Bug fixes and improvements" line. Running `Submit iOS` by hand with a version ships it even without iPhone changes. After each `Submit iOS` run, the `iOS dSYMs` workflow (`.github/workflows/ios-dsyms.yml` → `tools/upload-dsyms.py`, on macOS) downloads that release's archive from Xcode Cloud and uploads its dSYMs to PostHog (secret `POSTHOG_CLI_API_KEY`), so iPhone crash reports are symbolicated; run it by hand with a version after a manual `Submit iOS` or to upload an older one. `python3 tools/asc-submit-test.py` checks the PR parsing and the change detection. `DRY_RUN=1 tools/asc-submit.py <version>` prints the writes without making them.
+The Xcode Cloud workflow "Release" on the product "iOS" has no automatic start condition (its own tag trigger never fired); it only runs when started through the API, and it archives the `iOS` scheme in Release with deployment preparation **TestFlight and App Store** (the "Internal Testing Only" option produces builds App Review can't take) and uploads it to App Store Connect. Xcode Cloud overrides the build number with its own counter (`CI_BUILD_NUMBER`, configured under Xcode Cloud settings → Build Number in App Store Connect), so `CURRENT_PROJECT_VERSION` in `project.yml` is only the local default. The checked-in `apps/Codync.xcodeproj` is what the cloud builds: regenerate it whenever `project.yml` changes, and commit `apps/Codync.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved` whenever a package version changes (Xcode Cloud never resolves packages itself; copy `apps/ios/Kit/Package.resolved` there if Xcode wrote it to `apps/ios/Kit/`). Xcode Cloud reads public package repositories without any connection. The `Submit iOS` GitHub workflow (`.github/workflows/ios-submit.yml` → `tools/asc-submit.py`, secrets `ASC_KEY_ID`, `ASC_ISSUER_ID`, `ASC_PRIVATE_KEY`) runs on every `v*` tag (the tags Auto Tag pushes after a version bump on `main`). It compares the tag with the last version sent to the App Store: when nothing the iPhone app is built from changed (`apps/ios/` including `apps/ios/Kit/`, `apps/shared/`, the package pins, or `apps/project.yml` beyond its version lines), iOS skips that release, so host- or desktop-only releases neither build nor touch a version in review. Otherwise it starts the Xcode Cloud archive on the tag, waits for that build to finish processing and submits it for App Review, released automatically after approval. The latest version wins: a version still *Waiting for Review* is pulled back, renamed and resubmitted with the new build; one already *In Review* or approved is left alone (rerun the workflow with the version once it is out). *What's New* comes from the version's `## <version>` section in `apps/ios/WhatsNew.md` (one `### <locale>` per App Store language, written in the version bump); without one, the `### zh-Hant` / `### en-US` bullets under `## What's New` in the PR template are collected from every PR merged since the last App Store version (changes pushed to `main` without a PR add nothing); with neither, empty fields get a generic "Bug fixes and improvements" line. Running `Submit iOS` by hand with a version ships it even without iPhone changes. After each `Submit iOS` run, the `iOS dSYMs` workflow (`.github/workflows/ios-dsyms.yml` → `tools/upload-dsyms.py`, on macOS) downloads that release's archive from Xcode Cloud and uploads its dSYMs to PostHog (secret `POSTHOG_CLI_API_KEY`), so iPhone crash reports are symbolicated; run it by hand with a version after a manual `Submit iOS` or to upload an older one ([iPhone crash tracing](iphone-crash-tracing.md)). `python3 tools/asc-submit-test.py` checks the PR parsing and the change detection. `DRY_RUN=1 tools/asc-submit.py <version>` prints the writes without making them.
diff --git a/docs/guides/iphone-crash-tracing.md b/docs/guides/iphone-crash-tracing.md
new file mode 100644
index 00000000..2ccd043c
--- /dev/null
+++ b/docs/guides/iphone-crash-tracing.md
@@ -0,0 +1,108 @@
+# iPhone crash tracing
+
+How an iPhone crash reaches PostHog with readable frames, how to read one, and what to do when
+it isn't readable. What the reports may contain: [usage analytics](../features/analytics.md#error-tracking).
+Why it is built this way: [error tracking detail](../plans/error-tracking-detail.md) (A1, A2).
+
+## How a crash becomes readable
+
+1. **On the iPhone.** MetricKit hands the app the previous launch's crash on the next launch.
+ `CodyncKit` `CrashReports` sends it as a `$exception` (process `ios`) with PostHog `apple`
+ frames: `instruction_addr`, `image_addr` (where the binary was loaded: address minus
+ `offsetIntoBinaryTextSegment`), `module`, `in_app`, and `function` = `binary + offset` as the
+ fallback name. The event-level `$debug_images` lists each binary once: its UUID (`debug_id`,
+ uppercase) and load address. The event goes in the session the crashed launch ended in
+ (`$session_id`), not the launch that reported it.
+2. **At release.** After `Submit iOS`, the `iOS dSYMs` workflow (`.github/workflows/ios-dsyms.yml`,
+ macOS) runs `tools/upload-dsyms.py v<version>`: it finds the Xcode Cloud "Release" run on the
+ tag's commit, downloads the run's archive and uploads every `.dSYM` in it with
+ `posthog-cli dsym upload`. Each dSYM is stored under its binary's UUID. This happens while
+ the version waits for App Review, before the App Store releases it.
+3. **In PostHog.** Ingestion matches each frame's `image_addr` to a `$debug_images` entry, loads
+ the dSYM with that `debug_id` and looks up `instruction_addr − image_addr`: the frame gets its
+ function, file and line.
+
+Versions before 2.19.2 sent `Codync + <offset>` frames without addresses; read them by hand
+(below). From 2.19.2 on, iPhone crashes start new issues, since their frames changed shape.
+
+## Reading a crash
+
+- Error tracking, filtered to `process = ios`, `env = main` (versions above the latest `v*` tag
+ are a fork's). Frames run oldest first, the crashing one last.
+- Codync's own frames (`Codync`, `CodyncWidgets`, `CodyncNotificationService`) show function,
+ file and line. System frames (`SwiftUI`, `UIKitCore`, `libswift_Concurrency`, …) stay
+ `binary + offset`: Apple publishes no symbols for them.
+- The exception type and signal narrow it down: `EXC_BREAKPOINT` / `SIGTRAP` is a Swift trap
+ (force unwrap, `precondition`, a continuation resumed twice), `EXC_CRASH` / `SIGABRT` an abort
+ or an Objective-C exception (AVFAudio rejecting a microphone format), `EXC_BAD_ACCESS` /
+ `SIGSEGV` a bad memory access.
+- What led up to it: the same session's events (`app_opened`, `computer_paired`,
+ `voice_call_started`, …), on the issue's page or in SQL:
+
+ ```sql
+ SELECT event, timestamp FROM events
+ WHERE timestamp >= now() - INTERVAL 7 DAY AND properties.$session_id = '<session id>'
+ ORDER BY timestamp
+ ```
+
+## Versions before 2.19.2, by hand
+
+1. Find the version's Xcode Cloud run with the App Store Connect API (key and ids as in
+ `tools/asc-submit.py`): `GET /v1/ciWorkflows/44342080-ce08-4dc1-be35-34ce6cbb41b5/buildRuns?sort=-number`,
+ the run whose `sourceCommit.commitSha` is the tag's commit → `/v1/ciBuildRuns/<id>/actions` →
+ `/v1/ciBuildActions/<id>/artifacts` → the `ARCHIVE` artifact → `/v1/ciArtifacts/<id>` gives its
+ `downloadUrl` (a zipped `.xcarchive`, about 30 MB, with `dSYMs/Codync.app.dSYM`).
+2. Old frames give the offset in decimal. Add it to the default load address and look it up:
+
+ ```sh
+ atos -o Codync.app.dSYM/Contents/Resources/DWARF/Codync -arch arm64 -l 0x100000000 \
+ "$(printf '0x%x' $((0x100000000 + 5949552)))"
+ # URLSessionSocket.ping() (in Codync) (HostConnector.swift:99)
+ ```
+
+ `dwarfdump --uuid` on the dSYM shows which build it belongs to.
+
+## Uploading dSYMs by hand
+
+- **Actions → iOS dSYMs → Run workflow** with the version: after a `Submit iOS` run started by hand
+ (the automatic run only follows tag runs), when a run failed, or to upload an older version.
+ Uploading the same dSYMs again does nothing (PostHog keeps them by UUID).
+- **Locally** (macOS): `npm install -g @posthog/[email protected]`, then with `ASC_KEY_ID`,
+ `ASC_ISSUER_ID`, `ASC_PRIVATE_KEY`, `POSTHOG_CLI_API_KEY` and `POSTHOG_CLI_PROJECT_ID=649427`
+ set, `python3 tools/upload-dsyms.py v2.19.2` from a checkout with the tags (PyJWT installed).
+ `POSTHOG_CLI_DRY_RUN=true` checks the download and lists the dSYMs without uploading or a key.
+- What's uploaded: PostHog's error tracking settings (symbol sets), or the PostHog MCP
+ `error-tracking-symbol-sets-list`.
+
+## Checking the whole path
+
+Done once for 2.19.1 on 2026-10-19; repeat it after changing `CrashReports` or the workflow.
+
+1. Upload a version's dSYMs (above).
+2. Pick a function in that build: `nm <dSYM>/Contents/Resources/DWARF/Codync | xcrun swift-demangle`;
+ its address minus `0x100000000` is the offset.
+3. Get a real payload from `CrashReports.properties(callStack:…)` (a throwaway Kit test that
+ builds MetricKit JSON with that build's `binaryUUID`, an `address` = any load address +
+ offset, and writes the encoded properties to a file), then send it to `/batch/` as one
+ `$exception` with `env = dev`, `$process_person_profile: false` and a test `distinct_id`.
+4. A minute later, `properties.$exception_functions` and `$exception_sources` on that event name
+ the function and file. Resolve the test issue in PostHog with a note that it was a test.
+
+## The upload key
+
+`POSTHOG_CLI_API_KEY` (GitHub secret, set 2026-10-19) is the personal API key "Codync iOS dSYM
+upload (GitHub Actions)": only `error_tracking:write`, only the Codync App project. To replace
+it, create a key with the same scope (PostHog → Settings → Personal API keys), run
+`gh secret set POSTHOG_CLI_API_KEY --repo leepokai/Codync` with it, and delete the old key.
+
+## When frames stay unreadable
+
+| Symptom | Cause | Fix |
+|---|---|---|
+| Codync frames read `Codync + <offset>` on 2.19.2 or later | That version's dSYMs weren't uploaded | Check its `iOS dSYMs` run; run it by hand with the version |
+| `iOS dSYMs` was skipped | `Submit iOS` ran by hand, not on a tag | Run `iOS dSYMs` by hand |
+| "no Xcode Cloud archive … among the latest 30" | The release didn't change the iPhone app, or it's older than the last 30 runs | Nothing to upload, or upload it locally |
+| "Xcode Cloud build N failed" | That archive failed; the version wasn't built | Upload the dSYMs of the run that shipped |
+| `Failed to run dwarfdump` | Not on macOS | Run on macOS (the workflow uses `macos-latest`) |
+| posthog-cli 401 or 403 | Key revoked, or missing `error_tracking:write` on Codync App | Replace the key (above) |
+| Only system frames, no Codync frame | The crash happened inside the system (a SwiftUI update) | Look at the frames just before the system ones and at the session |
diff --git a/docs/investigations/posthog-errors-2026-10-19.md b/docs/investigations/posthog-errors-2026-10-19.md
index 2729c4dd..2752b82e 100644
--- a/docs/investigations/posthog-errors-2026-10-19.md
+++ b/docs/investigations/posthog-errors-2026-10-19.md
@@ -17,7 +17,8 @@ richer error detail is proposed in [error tracking detail](../plans/error-tracki
- **Desktop renderer frames**: the renderer bundle is reproducible. `git archive v2.18.0
apps/desktop`, link `node_modules`, `npx electron-vite build`: the same `index-<hash>.js`
comes out, so a frame's line and column map to source.
-- **iPhone frames** (`Codync + <offset>`, the offset into the binary's text segment): the dSYM of
+- **iPhone frames** (`Codync + <offset>`, the offset into the binary's text segment; from 2.19.2
+ PostHog symbolicates them, see [iPhone crash tracing](../guides/iphone-crash-tracing.md)): the dSYM of
that version comes from its Xcode Cloud run ([iOS releases](../guides/development.md#ios-releases-xcode-cloud)).
With the App Store Connect API: `GET /v1/ciProducts/<iOS product>/buildRuns?sort=-number` (the
commit message names the version) → `/v1/ciBuildRuns/<id>/actions` → `/v1/ciBuildActions/<id>/artifacts`;