From 83297bec0e078604d0f74c5a594424c42e92cc1d Mon Sep 17 00:00:00 2001 From: isaac <> Date: Mon, 1 Jun 2026 18:07:34 +0200 Subject: [PATCH] Re-apply dynamic watch bundle id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-applies commit 1120b9084e (reverted in ef2c1d47cc during install debugging). The install failure was proven to be the oversized watch binary (fixed by DEAD_CODE_STRIPPING), not the bundle-id mechanism — which was verified to produce a byte-identical artifact for ph.telegra.Telegraph. xcodebuild bakes PRODUCT_BUNDLE_IDENTIFIER=.watchkitapp and the watch Info.plist derives WKCompanionAppBundleIdentifier via $(PRODUCT_BUNDLE_IDENTIFIER:base), so the embedded watch app is correct for any host (ph.telegra.Telegraph and org.telegram.TelegramInternal/enterprise) with no post-build plist patching. Co-Authored-By: Claude Opus 4.8 (1M context) --- Telegram/BUILD | 8 ++++++++ Telegram/WatchApp/tgwatch Watch App/Info.plist | 2 +- Telegram/prebuilt_watchos.bzl | 6 ++++++ Telegram/prebuilt_watchos_build.sh | 11 ++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Telegram/BUILD b/Telegram/BUILD index 0ed745668f..ef5fa5dbdf 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -1746,6 +1746,14 @@ xcode_provisioning_profile( apple_prebuilt_watchos_application( name = "TelegramWatchApp", + # Watch bundle id tracks the host config (".watchkitapp"). The rule passes it + # to xcodebuild as PRODUCT_BUNDLE_IDENTIFIER (baked + signed); the watch Info.plist + # derives WKCompanionAppBundleIdentifier from it via $(PRODUCT_BUNDLE_IDENTIFIER:base), + # so the embedded watch app is correct for any host (ph.telegra.Telegraph, + # org.telegram.TelegramInternal, ...) with no post-build plist patching. + bundle_id = "{telegram_bundle_id}.watchkitapp".format( + telegram_bundle_id = telegram_bundle_id, + ), tags = ["manual"], ) diff --git a/Telegram/WatchApp/tgwatch Watch App/Info.plist b/Telegram/WatchApp/tgwatch Watch App/Info.plist index 1d426f5632..ca62526111 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Info.plist +++ b/Telegram/WatchApp/tgwatch Watch App/Info.plist @@ -38,7 +38,7 @@ WKApplication WKCompanionAppBundleIdentifier - ph.telegra.Telegraph + $(PRODUCT_BUNDLE_IDENTIFIER:base) WKRunsIndependentlyOfCompanionApp diff --git a/Telegram/prebuilt_watchos.bzl b/Telegram/prebuilt_watchos.bzl index f4ce9d66ad..3002c45892 100644 --- a/Telegram/prebuilt_watchos.bzl +++ b/Telegram/prebuilt_watchos.bzl @@ -70,6 +70,12 @@ def _apple_prebuilt_watchos_application_impl(ctx): infoplist.path, ctx.file.versions_json.path, build_number, + # Watch app bundle id (".watchkitapp"). xcodebuild bakes it as + # PRODUCT_BUNDLE_IDENTIFIER so the signed CFBundleIdentifier matches the host + # config; the Info.plist derives WKCompanionAppBundleIdentifier from it via + # $(PRODUCT_BUNDLE_IDENTIFIER:base). Keeps the build dynamic across hosts with + # no post-build plist mutation (xcodebuild bakes, the worker signs once). + ctx.attr.bundle_id, ], inputs = inputs, outputs = [archive, infoplist], diff --git a/Telegram/prebuilt_watchos_build.sh b/Telegram/prebuilt_watchos_build.sh index 1e1a4d537b..9acc2fd93e 100755 --- a/Telegram/prebuilt_watchos_build.sh +++ b/Telegram/prebuilt_watchos_build.sh @@ -17,9 +17,17 @@ # $4 api_hash TG_API_HASH build setting # $5 identity Codesigning identity (SHA1 hash); empty => derived from $6's cert # $6 profile Path to the watchkitapp .mobileprovision; empty => unsigned build +# $7 infoplist Path (declared by Bazel) to copy the built Info.plist to +# $8 versions_json versions.json (key 'app' => CFBundleShortVersionString) +# $9 build_number CFBundleVersion +# $10 watch_bundle_id PRODUCT_BUNDLE_IDENTIFIER for xcodebuild (the watch app id, +# ".watchkitapp"); empty => keep the project default. xcodebuild +# bakes it into CFBundleIdentifier (and signs with it); the Info.plist +# derives WKCompanionAppBundleIdentifier from it via +# $(PRODUCT_BUNDLE_IDENTIFIER:base), so no post-build plist patching. set -euo pipefail -SRC="$1"; OUT_ZIP="$2"; API_ID="$3"; API_HASH="$4"; IDENTITY="${5:-}"; PROFILE="${6:-}"; INFOPLIST_OUT="${7:-}"; VERSIONS_JSON="${8:-}"; BUILD_NUMBER="${9:-1}" +SRC="$1"; OUT_ZIP="$2"; API_ID="$3"; API_HASH="$4"; IDENTITY="${5:-}"; PROFILE="${6:-}"; INFOPLIST_OUT="${7:-}"; VERSIONS_JSON="${8:-}"; BUILD_NUMBER="${9:-1}"; WATCH_BUNDLE_ID="${10:-}" if [ ! -e "$SRC/tgwatch.xcodeproj" ]; then echo "error: no tgwatch.xcodeproj at $SRC (re-sync the Telegram/WatchApp snapshot via tgwatch/tools/export-sources.sh)" >&2 @@ -53,6 +61,7 @@ xcodebuild \ CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" \ TG_API_ID="$API_ID" TG_API_HASH="$API_HASH" \ MARKETING_VERSION="$MARKETING_VERSION" CURRENT_PROJECT_VERSION="$BUILD_NUMBER" \ + ${WATCH_BUNDLE_ID:+PRODUCT_BUNDLE_IDENTIFIER="$WATCH_BUNDLE_ID"} \ build 1>&2 APP="$(find "$DD/Build/Products" -maxdepth 2 -name 'tgwatch Watch App.app' -type d | head -1)"