From 906e2f194d4f5fc73b29c4dece1b6054cd74031a Mon Sep 17 00:00:00 2001 From: devthejo Date: Mon, 12 Jan 2026 18:29:30 +0100 Subject: [PATCH] fix(ios): bundle release version --- package.json | 3 ++ scripts/ios-set-testflight-build-number.sh | 41 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 scripts/ios-set-testflight-build-number.sh diff --git a/package.json b/package.json index 812c91c..219777d 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,9 @@ "bundle:ios:export": "./scripts/ios-export.sh", "bundle:ios:upload": "./scripts/ios-upload.sh", "bundle:ios": "yarn bundle:ios:archive && yarn bundle:ios:export", + "bundle:ios:testflight:version": "bash ./scripts/ios-set-testflight-build-number.sh", + "bundle:ios:testflight:archive": "yarn bundle:ios:testflight:version && yarn bundle:ios:archive", + "bundle:ios:testflight": "yarn bundle:ios:testflight:archive && yarn bundle:ios:export && yarn bundle:ios:upload", "ios": "expo run:ios", "ios:staging": "dotenv --override -e .env.staging -- yarn run ios", "ios:prod": "dotenv --override -e .env.prod -- yarn run ios", diff --git a/scripts/ios-set-testflight-build-number.sh b/scripts/ios-set-testflight-build-number.sh new file mode 100644 index 0000000..fae637e --- /dev/null +++ b/scripts/ios-set-testflight-build-number.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -euo pipefail + +PROJECT_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +INFO_PLIST_PATH="$PROJECT_ROOT_DIR/ios/AlerteSecours/Info.plist" + +if [ ! -f "$INFO_PLIST_PATH" ]; then + echo "error: Info.plist not found at $INFO_PLIST_PATH" >&2 + exit 1 +fi + +# Generate a unique version/build number for TestFlight in Europe/Paris timezone +# This value will be used for both CFBundleShortVersionString and CFBundleVersion. +# Format: YYYYMMDDHHMM, e.g. 202601121110 (valid as a numeric-only iOS version). +BUILD_NUMBER="$(TZ=Europe/Paris date +%Y%m%d%H%M)" + +echo "[ios-set-testflight-build-number] Using build number: $BUILD_NUMBER" + +PLISTBUDDY="/usr/libexec/PlistBuddy" + +if [ ! -x "$PLISTBUDDY" ]; then + echo "error: $PLISTBUDDY not found or not executable. This script must run on macOS with PlistBuddy available." >&2 + exit 1 +fi + +set_plist_version_key() { + local key="$1" + # Try to set the existing key, or add it if it does not exist yet. + if ! "$PLISTBUDDY" -c "Set :$key $BUILD_NUMBER" "$INFO_PLIST_PATH" 2>/dev/null; then + "$PLISTBUDDY" -c "Add :$key string $BUILD_NUMBER" "$INFO_PLIST_PATH" + fi +} + +set_plist_version_key "CFBundleVersion" +set_plist_version_key "CFBundleShortVersionString" + +echo "[ios-set-testflight-build-number] Updated CFBundleShortVersionString and CFBundleVersion in $INFO_PLIST_PATH to $BUILD_NUMBER" + +# Print the build number on stdout so callers can capture/log it easily. +echo "$BUILD_NUMBER"