From 109e5c964eda27737fb3532566159db91f5263a8 Mon Sep 17 00:00:00 2001 From: Roman <51091564+jeanpierreroma@users.noreply.github.com> Date: Tue, 11 Aug 2026 17:02:46 +0300 Subject: [PATCH] fix(swift-sdk): build the shippable profile by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `build_ios.sh` defaulted to `--profile dev`, which maps to `dev-ios`: Cargo's `dev` defaults (debug assertions and overflow checks on, opt-level 0) plus `panic = "abort"`. Every `debug_assert!` in dash-spv, key-wallet and platform-wallet is therefore live in such a build, and aborts the host process instead of degrading. That is correct for local iteration and wrong for anything a tester touches — and it has already happened. A TestFlight build of the wallet (9.0.0/25) died with SIGABRT inside `FiltersManager::start_download` at `filters/manager.rs:182`, which is `debug_assert!(self.is_idle(), ...)`. A release build would have compiled that line out entirely. The same build's logs carry `platform_wallet_ffi::metrics` lines, which `build_ios.sh` only enables under `dev-ios` — so the profile, not the assert, is what made an internal invariant a user-visible crash. The default is now `release`; `dev` stays available and prints a warning naming what it implies. Both CI callers pass `--profile` explicitly (`release-swift-sdk.yml` release, `swift-example-app-ui-smoke.yml` dev), so neither changes behaviour. The trade-off is deliberate: an unqualified `./build_ios.sh` is now slow (fat LTO, opt-level 3) where it used to be fast. A developer who wants the fast one asks for it by name; nobody ships the slow-to-notice one by forgetting to. --- AGENTS.md | 4 +++- packages/swift-sdk/build_ios.sh | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b0ad729230f..8189bf17eab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -121,7 +121,9 @@ Quick build commands: ```bash # Build unified iOS framework (includes Core + Platform) cd packages/swift-sdk -./build_ios.sh +./build_ios.sh --target sim # release profile (the default) +./build_ios.sh --target sim --profile dev # local iteration ONLY — debug + # assertions abort the host app # Build SwiftExampleApp cd packages/swift-sdk diff --git a/packages/swift-sdk/build_ios.sh b/packages/swift-sdk/build_ios.sh index 94d0acff68c..54c125a72d7 100755 --- a/packages/swift-sdk/build_ios.sh +++ b/packages/swift-sdk/build_ios.sh @@ -13,6 +13,7 @@ export MACOSX_DEPLOYMENT_TARGET # ------------------------------- RED="\033[0;31m" GREEN="\033[0;32m" +YELLOW="\033[0;33m" NC="\033[0m" # ------------------------------- @@ -23,7 +24,7 @@ ROOT_DIR="$SCRIPT_DIR/../../" TARGET_DIR="$ROOT_DIR/target" PACKAGE="rs-unified-sdk-ffi" XCFRAMEWORK="$SCRIPT_DIR/DashSDKFFI.xcframework" -PROFILE="dev" +PROFILE="release" PRUNE_CARGO_TARGETS="${PRUNE_CARGO_TARGETS:-0}" STAGING_DIR="" @@ -47,6 +48,7 @@ CLEAN=false log_info() { echo -e "${GREEN}$1${NC}"; } log_error() { echo -e "${RED}$1${NC}"; } +log_warn() { echo -e "${YELLOW}$1${NC}"; } cleanup_staging_dir() { if [ -n "$STAGING_DIR" ]; then @@ -87,8 +89,11 @@ show_help() { echo " tests -> targets needed by run_tests.sh (sim + mac)" echo "" echo "Profile:" - echo " dev (default)" - echo " release" + echo " release (default) -> ships: optimized, no debug assertions" + echo " dev -> local iteration: fast to build, debug" + echo " assertions ON, tokio-metrics ON. A dev" + echo " build turns every internal invariant into" + echo " an abort() and must never be distributed." echo "" echo "Examples:" echo " $0 --target sim --profile release" @@ -154,6 +159,18 @@ OUTPUT_DIR="$PROFILE" log_info "Package: $PACKAGE" log_info "Profile: $PROFILE" +# `dev-ios` inherits Cargo's `dev` defaults, so debug assertions are live — +# and it pairs them with `panic = "abort"`. Any debug_assert! in dash-spv, +# key-wallet or platform-wallet therefore terminates the host process rather +# than degrading. That is what a dev build is for locally, and exactly why one +# must not reach testers; a shipped dev build has already crashed a TestFlight +# release this way. Loud on purpose, since the failure is invisible until a +# device aborts weeks later. +if [ "$PROFILE" = "dev-ios" ]; then + log_warn "dev profile: debug assertions ON (panic = abort) — NOT distributable" + log_warn " build shipping artifacts with: $0 --target all --profile release" +fi + if [ "$PRUNE_CARGO_TARGETS" = "1" ]; then STAGING_DIR="$(mktemp -d "${TMPDIR:-/tmp}/dash-sdk-ffi.XXXXXX")" trap cleanup_staging_dir EXIT