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.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix(ios): keep the app opening on iOS 27.2 betas
leepokai66ce59b78e7f
diff --git a/.github/workflows/ios-dsyms.yml b/.github/workflows/ios-dsyms.ymlindex 83e3442c..39f87fdc 100644--- a/.github/workflows/ios-dsyms.yml+++ b/.github/workflows/ios-dsyms.yml@@ -1,7 +1,8 @@name: iOS dSYMs# After Submit iOS, uploads the dSYMs from that release's Xcode Cloud archive to PostHog, so iPhone-# crash reports show function, file and line (tools/upload-dsyms.py). By hand: any version.+# crash reports show function, file and line, then fails on a weak import from Foundation in that+# archive's app (tools/upload-dsyms.py). By hand: any version.on:workflow_run:workflows: ["Submit iOS"]@@ -19,7 +20,7 @@ jobs:upload:# A manual Submit iOS ran on a branch, not the release commit: run this by hand after it.if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.event == 'push'- # posthog-cli reads dSYMs with Xcode's dwarfdump.+ # posthog-cli reads dSYMs with Xcode's dwarfdump; the check uses dyld_info.runs-on: macos-latesttimeout-minutes: 150steps:diff --git a/apps/ios/Kit/Sources/CodyncKit/DateComparisons.swift b/apps/ios/Kit/Sources/CodyncKit/DateComparisons.swiftnew file mode 100644index 00000000..c45e28c5--- /dev/null+++ b/apps/ios/Kit/Sources/CodyncKit/DateComparisons.swift@@ -0,0 +1,27 @@+import Foundation++// Xcode 27.2's SDK back-deploys Date's <= and >= (before: iOS 27.2). Every direct comparison, ours and+// a package's alike, then compiles to "if the OS is at least 27.2, call Foundation's copy, else compare+// here", and that call has no nil check. An iOS 27.2 beta seed that lacks the symbol jumped to address 0,+// which killed the app at launch once an account was signed in (#350).+//+// These carry the mangled names of Foundation's two operators, so the linker binds every such call in+// this binary here and imports nothing weakly. They compare as the back-deployed copies do. Only the test+// calls them by name. They stay public because Xcode prelinks a package target into one object, which hides+// anything less from the other targets, and static methods of Date so a direct comparison in this module+// still compiles (a global function fails, on the 27.2 SDK only).+//+// ponytail: these two symbols only. tools/check-ios-weak-imports.py checks each release's archive for the+// next weak import from Foundation, not from other frameworks. Delete this once the deployment target+// reaches iOS 27.2.+extension Date {+ @_silgen_name("$s10Foundation4DateV2leoiySbAC_ACtFZ")+ public static func _lessOrEqual(_ lhs: Date, _ rhs: Date) -> Bool {+ lhs.timeIntervalSinceReferenceDate <= rhs.timeIntervalSinceReferenceDate+ }++ @_silgen_name("$s10Foundation4DateV2geoiySbAC_ACtFZ")+ public static func _greaterOrEqual(_ lhs: Date, _ rhs: Date) -> Bool {+ lhs.timeIntervalSinceReferenceDate >= rhs.timeIntervalSinceReferenceDate+ }+}diff --git a/apps/ios/Kit/Tests/CodyncKitTests/DateComparisonsTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/DateComparisonsTests.swiftnew file mode 100644index 00000000..dd1f5c2a--- /dev/null+++ b/apps/ios/Kit/Tests/CodyncKitTests/DateComparisonsTests.swift@@ -0,0 +1,28 @@+import CodyncKit+import Foundation+import Testing++// Reached by symbol name, as the SDK's back-deployment thunks reach them (#350), which checks the names and+// the calling convention. Without CodyncKit's definitions this fails to link only on an SDK that doesn't+// export the symbols: a 27.2 SDK binds it to Foundation's. The direct calls below fail on every SDK, and a+// definition that only loses its @_silgen_name is left to tools/check-ios-weak-imports.py.+private extension Date {+ @_silgen_name("$s10Foundation4DateV2leoiySbAC_ACtFZ")+ static func boundLessOrEqual(_ lhs: Date, _ rhs: Date) -> Bool++ @_silgen_name("$s10Foundation4DateV2geoiySbAC_ACtFZ")+ static func boundGreaterOrEqual(_ lhs: Date, _ rhs: Date) -> Bool+}++@Test func dateComparisonsAnswerUnderFoundationsSymbols() {+ let earlier = Date(timeIntervalSinceReferenceDate: 1)+ let later = Date(timeIntervalSinceReferenceDate: 2)+ #expect(Date.boundLessOrEqual(earlier, later))+ #expect(Date.boundLessOrEqual(earlier, earlier))+ #expect(!Date.boundLessOrEqual(later, earlier))+ #expect(Date.boundGreaterOrEqual(later, earlier))+ #expect(Date.boundGreaterOrEqual(later, later))+ #expect(!Date.boundGreaterOrEqual(earlier, later))+ #expect(Date._lessOrEqual(earlier, later))+ #expect(Date._greaterOrEqual(later, earlier))+}diff --git a/docs/guides/development.md b/docs/guides/development.mdindex a6f95f23..f23bf129 100644--- a/docs/guides/development.md+++ b/docs/guides/development.md@@ -190,7 +190,7 @@ The mirror only fast-forwards: the crate's commits must reach `main` as they are## 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 App Review (a version never sent or pulled back, such as one a failed run left behind, doesn't count; a rejected one does): when nothing the iPhone app is built from changed (`apps/ios/` including `apps/ios/Kit/`, except `WhatsNew.md` and the Kit tests, `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; a release whose host asks for a newer iPhone app (`MIN_APP`) than that version ships anyway, so the release gate never waits for an iPhone app that isn't coming. Otherwise it starts the Xcode Cloud archive on the tag (or on `main` while `main` is the tagged commit: Xcode Cloud hears of a new tag through a GitHub webhook that sometimes never arrives), 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: iPhone` 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, the change detection, the `MIN_APP` check (all three in `tools/store_release.py`, shared with Google Play) and the archive source. `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 App Review (a version never sent or pulled back, such as one a failed run left behind, doesn't count; a rejected one does): when nothing the iPhone app is built from changed (`apps/ios/` including `apps/ios/Kit/`, except `WhatsNew.md` and the Kit tests, `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; a release whose host asks for a newer iPhone app (`MIN_APP`) than that version ships anyway, so the release gate never waits for an iPhone app that isn't coming. Otherwise it starts the Xcode Cloud archive on the tag (or on `main` while `main` is the tagged commit: Xcode Cloud hears of a new tag through a GitHub webhook that sometimes never arrives), 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: iPhone` 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)). The workflow's Xcode is "Latest Release", so a new SDK reaches the next release unasked: `iOS dSYMs` also [checks each archive for weak imports from Foundation](iphone-crash-tracing.md#a-crash-at-address-0-after-a-back-deployment-thunk), and a red run means pulling back a version still waiting for review. `python3 tools/asc-submit-test.py` checks the PR parsing, the change detection, the `MIN_APP` check (all three in `tools/store_release.py`, shared with Google Play) and the archive source. `DRY_RUN=1 tools/asc-submit.py <version>` prints the writes without making them.## Android releases (Google Play)diff --git a/docs/guides/iphone-crash-tracing.md b/docs/guides/iphone-crash-tracing.mdindex 2ccd043c..0e376f1a 100644--- a/docs/guides/iphone-crash-tracing.md+++ b/docs/guides/iphone-crash-tracing.md@@ -17,7 +17,8 @@ Why it is built this way: [error tracking detail](../plans/error-tracking-detailmacOS) runs `tools/upload-dsyms.py v<version>`: it finds the Xcode Cloud "Release" run on thetag'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.+ the version waits for App Review, before the App Store releases it. Then it+ [checks the app](#a-crash-at-address-0-after-a-back-deployment-thunk) for weak imports from Foundation.3. **In PostHog.** Ingestion matches each frame's `image_addr` to a `$debug_images` entry, loadsthe dSYM with that `debug_id` and looks up `instruction_addr − image_addr`: the frame gets itsfunction, file and line.@@ -45,6 +46,38 @@ Versions before 2.19.2 sent `Codync + <offset>` frames without addresses; read tORDER BY timestamp```+## A crash at address 0 after a back deployment thunk++A stack ending `back deployment thunk for …` → `??? + 0` (`pc: 0`, `EXC_BAD_ACCESS`; the device's own+report may say CODESIGNING) means an SDK's `@backDeployed` API ran on an OS that reports the new version+but lacks the symbol, such as an early beta seed. The thunk checks only the OS version, then calls the weak+import, which is address 0. No code of ours has to change for this to start: the Xcode Cloud workflow builds+with "Latest Release", so the next SDK arrives by itself. MetricKit may never report it, since a crash at+launch can kill the app before anything is sent.++[#350](https://github.com/leepokai/Codync/issues/350) was Xcode 27.2's `Date.<=` and `>=`, called from Clerk+and from `CodyncUI`. `CodyncKit/DateComparisons.swift` defines both under Foundation's symbol names, so every+call in the binary, a package's included, binds there and nothing is imported weakly.++**Every release's archive is checked.** After uploading the dSYMs, `tools/upload-dsyms.py` runs+`tools/check-ios-weak-imports.py` on the app and its extensions, and any weak import from Foundation turns the+`iOS dSYMs` run red. It doesn't gate the release (`Submit iOS` runs on Linux, which has no `dyld_info`) and the+version is already in App Review by then, so pull it back while it still waits. Weak imports from other+frameworks aren't checked: most are ordinary `if #available` calls. Run by hand on a version built with Xcode 27.2+before this fix, the workflow goes red after its upload.++For any other archive, `python3 tools/check-ios-weak-imports.py <Codync.app>`. A local build on an older SDK+always passes, so only an Xcode Cloud archive counts.++**Reproduce it without the beta** on a Mac: `cp -cR` the SDK, then in the copy add the back-deployed+declaration to `Foundation.swiftmodule/*.swiftinterface` (`@backDeployed(before:)` at or below the running OS,+body as in the thunk's fallback) and its symbol to `Foundation.tbd`. Anything built against that copy+(`swiftc -sdk`, or `xcodebuild … SDKROOT=<copy>`) gets the same thunk and, run on that OS, the same crash. On a+simulator of that version, a Codync Dev signed in with `npm run phone-account` then crashes as #350 did, at+sign-in, at every launch and after a reinstall. Keep the copy under `<name>.platform/Developer/SDKs/` with+`Developer/usr` linked to Xcode's, or macro plugins aren't found (a simulator SDK looks in the sibling+`iPhoneOS.platform`).+## Versions before 2.19.2, by hand1. Find the version's Xcode Cloud run with the App Store Connect API (key and ids as indiff --git a/tools/check-ios-weak-imports.py b/tools/check-ios-weak-imports.pynew file mode 100644index 00000000..2edb509d--- /dev/null+++ b/tools/check-ios-weak-imports.py@@ -0,0 +1,53 @@+#!/usr/bin/env python3+"""Fail when an iPhone build reaches Foundation through a weak import.++Usage: check-ios-weak-imports.py <Codync.app or a Mach-O binary> (macOS: uses dyld_info)++An SDK's @backDeployed API compiles to a thunk: "if the OS is at least X, call the OS's copy, else run+the copy built into the app". The call has no nil check, so an OS that reports X without having the+symbol (an early beta seed of X) jumps to address 0. Xcode 27.2's SDK does this to Date's <= and >=+(before: iOS 27.2), which killed the app at launch on such seeds once an account was signed in (#350).+CodyncKit's DateComparisons.swift now defines those two in the binary. SDK 27.1 builds import nothing+weakly from Foundation, so any such import is new and gets a look. upload-dsyms.py runs this on every+release's archive. Local builds on an older SDK always pass: only an Xcode Cloud archive proves anything+(docs/guides/iphone-crash-tracing.md).+"""++import re+import subprocess+import sys+from pathlib import Path++IMPORT = re.compile(r"^\s*0x[0-9a-fA-F]+\s+(\S+)\s+(\[weak-import\]\s+)?\(from (\S+)\)")+++def foundation_weak_imports(binary):+ """The symbols `binary` imports weakly from Foundation."""+ output = subprocess.run(["dyld_info", "-imports", str(binary)], capture_output=True, text=True, check=True).stdout+ imports = [m for m in map(IMPORT.match, output.splitlines()) if m]+ if not imports:+ sys.exit(f"{binary}: found no imports in dyld_info's output; has its format changed?")+ return sorted(m[1] for m in imports if m[2] and m[3] == "Foundation")+++def binaries(path):+ """The Mach-O files of a .app (the app and its extensions), or `path` itself."""+ if path.suffix != ".app":+ return [path]+ appexes = sorted(path.glob("PlugIns/*.appex"))+ return [bundle / bundle.stem for bundle in [path, *appexes]]+++def main(path):+ failed = False+ for binary in binaries(Path(path)):+ found = foundation_weak_imports(binary)+ print(f"{binary.name}: {len(found)} weak imports from Foundation")+ for symbol in found:+ print(f" {symbol}")+ failed = failed or bool(found)+ sys.exit(1 if failed else 0)+++if __name__ == "__main__":+ main(sys.argv[1])diff --git a/tools/upload-dsyms.py b/tools/upload-dsyms.pyindex 11b57883..ae1fe90f 100755--- a/tools/upload-dsyms.py+++ b/tools/upload-dsyms.py@@ -1,13 +1,15 @@#!/usr/bin/env python3-"""Upload an iPhone release's dSYMs to PostHog, so its crash reports show function, file and line.+"""Upload an iPhone release's dSYMs to PostHog, so its crash reports show function, file and line, then+check its app for weak imports from Foundation (check-ios-weak-imports.py).Usage: upload-dsyms.py v2.19.2 (a release tag or its commit)Env: ASC_KEY_ID, ASC_ISSUER_ID, ASC_PRIVATE_KEY (as asc-submit.py); POSTHOG_CLI_API_KEY (a personalAPI key with error tracking write) and POSTHOG_CLI_PROJECT_ID for posthog-cli, which must be on PATH.-macOS only: posthog-cli reads dSYMs with Xcode's dwarfdump. Runs in a checkout with the release tags.+macOS only: posthog-cli reads dSYMs with Xcode's dwarfdump, the check uses dyld_info. Runs in a checkout+with the release tags.-Finds the Xcode Cloud "Release" run on that commit, waits for it, downloads its archive and uploads-the dSYMs inside. A release that didn't build the iPhone app has no run and nothing to upload.+Finds the Xcode Cloud "Release" run on that commit, waits for it, downloads its archive, uploads the dSYMs+inside and checks the app. A release that didn't build the iPhone app has no run and nothing to upload."""import importlib.util@@ -61,8 +63,10 @@ def main(ref):archive = Path(tmp, "archive.zip")urllib.request.urlretrieve(archive_url(run["id"]), archive)dsyms = Path(tmp, "dSYMs")+ apps = Path(tmp, "apps")with zipfile.ZipFile(archive) as z:z.extractall(dsyms, [n for n in z.namelist() if ".dSYM/" in n])+ z.extractall(apps, [n for n in z.namelist() if ".app/" in n])names = sorted(p.name for p in dsyms.rglob("*.dSYM"))if not names:sys.exit(f"Xcode Cloud build {number}'s archive has no dSYMs")@@ -70,6 +74,13 @@ def main(ref):# posthog-cli finds every .dSYM bundle under the directory.subprocess.run(["posthog-cli", "dsym", "upload", "--directory", str(dsyms)], check=True)+ # After the upload: a failed check still leaves this release's crash reports readable.+ app = next(apps.rglob("Codync.app"), None)+ if not app:+ sys.exit(f"Xcode Cloud build {number}'s archive has no Codync.app")+ checker = Path(__file__).with_name("check-ios-weak-imports.py")+ subprocess.run([sys.executable, str(checker), str(app)], check=True)+if __name__ == "__main__":main(sys.argv[1])