From ce1ad286cb44e3c2d6e9dc27539bb865328f46f6 Mon Sep 17 00:00:00 2001 From: devthejo Date: Mon, 12 Jan 2026 23:09:09 +0100 Subject: [PATCH] chore(ios): fix bundle scripts --- DEVELOPER.md | 24 +++++++++---- package.json | 10 +++--- scripts/ios-set-testflight-build-number.sh | 41 +++------------------ scripts/ios-set-timestamp-build-number.sh | 42 ++++++++++++++++++++++ 4 files changed, 69 insertions(+), 48 deletions(-) create mode 100644 scripts/ios-set-timestamp-build-number.sh diff --git a/DEVELOPER.md b/DEVELOPER.md index 43e7bbc..0ecfb9f 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -137,15 +137,25 @@ If you need to install the app manually, you can examine the `install-android.sh #### Building and Running -To build and run the iOS app: + To build and run the iOS app: -```bash -# Run in development mode with staging environment -yarn ios:staging + ```bash + # Run in development mode with staging environment + yarn ios:staging -# Build for production (uses scripts/ios-archive.sh and scripts/ios-export.sh) -yarn bundle:ios -``` + # Build for production (version + clean + archive + export) + yarn bundle:ios:build + + # Upload the last build to App Store Connect + yarn bundle:ios:upload + + # Build + upload + yarn bundle:ios:release + ``` + + Notes on versioning: + - `yarn bundle:ios:build` updates iOS `CFBundleShortVersionString` and `CFBundleVersion` to a timestamp in `Europe/Paris` timezone (format `YYYYMMDDHHMM`) before archiving/exporting. + - `yarn bundle:ios` is an alias of `yarn bundle:ios:build`. The `bundle:ios` command uses the scripts in the `scripts` directory: - `ios-archive.sh` - Archives the iOS app diff --git a/package.json b/package.json index 67a541d..205ee30 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,10 @@ "bundle:ios:archive": "./scripts/ios-archive.sh", "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", + "bundle:ios:version": "bash ./scripts/ios-set-timestamp-build-number.sh | tail -n 1 | xargs -I{} echo 'iOS version timestamp: {}'", + "bundle:ios:build": "yarn bundle:ios:version && yarn bundle:ios:archive && yarn bundle:ios:export", + "bundle:ios:release": "yarn bundle:ios:build && yarn bundle:ios:upload", + "bundle:ios": "yarn bundle:ios:build", "ios": "expo run:ios", "ios:staging": "dotenv --override -e .env.staging -- yarn run ios", "ios:prod": "dotenv --override -e .env.prod -- yarn run ios", @@ -283,4 +283,4 @@ } }, "packageManager": "yarn@4.5.3" -} \ No newline at end of file +} diff --git a/scripts/ios-set-testflight-build-number.sh b/scripts/ios-set-testflight-build-number.sh index fae637e..50c0855 100644 --- a/scripts/ios-set-testflight-build-number.sh +++ b/scripts/ios-set-testflight-build-number.sh @@ -2,40 +2,9 @@ set -euo pipefail -PROJECT_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -INFO_PLIST_PATH="$PROJECT_ROOT_DIR/ios/AlerteSecours/Info.plist" +# Backward compatible wrapper. +# Historically this script was TestFlight-specific, but iOS builds now use the same +# timestamp versioning for all distribution bundles. +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -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" +exec "$SCRIPT_DIR/ios-set-timestamp-build-number.sh" diff --git a/scripts/ios-set-timestamp-build-number.sh b/scripts/ios-set-timestamp-build-number.sh new file mode 100644 index 0000000..83c94e2 --- /dev/null +++ b/scripts/ios-set-timestamp-build-number.sh @@ -0,0 +1,42 @@ +#!/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 timestamp version/build number 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-timestamp-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-timestamp-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" +