Files
firebase-ios-sdk/scripts/quickstart_build_spm.sh
Andrew Heard 1be8e1fb6b fix(infra): fix quickstart SPM dependency update (#16847)
Update scripts/update_firebase_spm_dependency.sh and
scripts/quickstart_build_spm.sh to reliably update SPM dependencies
across quickstart projects (such as FirebaseAI) in CI.

Key changes:
- Match any requirement type (branch, revision, exactVersion) using
  Perl \K and preserve trailing package attributes like traits.
- Fix --version mode to map to exactVersion instead of branch.
- Pass parameters to Perl via environment variables to prevent regex
  delimiter collisions and variable interpolation issues.
- Add an exit/signal trap with a backup_successful guard to safely
  restore project.pbxproj on failure.
- Run update script as a subprocess rather than sourcing in quickstart
  build script, passing FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT
  explicitly to test.sh.
- Copy mock GoogleService-Info.plist to both sample and nested app
  directories for Xcode 16 synchronized groups.
- Format scripts to adhere to the Google Shell Style Guide and pass
  shellcheck with zero warnings.
2026-10-05 18:44:00 -04:00

75 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Verifies changes to firebase-ios-sdk repo can continue to build the
# product's SPM quickstart.
set -euo pipefail
if [[ "${DEBUG:-false}" == "true" ]]; then
set -x
fi
if [[ $# -lt 1 ]]; then
echo "Usage: ${0} <sample_name>" >&2
exit 1
fi
sample="${1}"
branch_name="${BRANCH_NAME:-main}"
sample_dir="$(echo "${sample}" | tr '[:upper:]' '[:lower:]')"
sample_xcodeproj="${sample_dir}/${sample}Example.xcodeproj"
scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
"${scripts_dir}/setup_bundler.sh"
if ! command -v xcpretty >/dev/null 2>&1; then
gem install --no-document xcpretty
fi
if [[ ! -d "quickstart-ios" ]]; then
git clone --depth 1 https://github.com/firebase/quickstart-ios.git
fi
cd quickstart-ios
if [[ ! -d "${sample_xcodeproj}" ]]; then
echo "Error: Project ${sample_xcodeproj} does not exist in quickstart-ios." \
>&2
exit 1
fi
# Execute updater script rather than sourcing to isolate state
"${scripts_dir}/update_firebase_spm_dependency.sh" \
"${sample_xcodeproj}" \
--branch "${branch_name}"
# Placeholder GoogleService-Info.plist good enough for build-only testing.
cp ./mock-GoogleService-Info.plist "./${sample_dir}/GoogleService-Info.plist"
if [[ -d "./${sample_dir}/${sample}Example" ]]; then
cp ./mock-GoogleService-Info.plist \
"./${sample_dir}/${sample}Example/GoogleService-Info.plist"
fi
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1 \
SAMPLE="${sample}" \
DIR="${sample_dir}" \
SPM="true" \
TEST="false" \
./scripts/test.sh