diff --git a/.github/actions/setup_simulator/action.yml b/.github/actions/setup_simulator/action.yml new file mode 100644 index 000000000..1bb56b9a6 --- /dev/null +++ b/.github/actions/setup_simulator/action.yml @@ -0,0 +1,37 @@ +# Copyright 2026 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. + +# TODO: Temporary local copy of firebase/firebase-ios-sdk's setup_simulator +# composite action. Consolidate to reference +# `firebase/firebase-ios-sdk/.github/actions/setup_simulator` once upstream +# resolves its script path via `$GITHUB_ACTION_PATH` instead of +# `github.workspace` and supports `macOS|catalyst` as a no-op. + +name: 'Setup Simulator' +description: 'Creates a standardized simulator matching the active Xcode runtime.' +inputs: + platform: + description: 'The platform to create a simulator for (iOS, tvOS, watchOS, visionOS, all). Default is all.' + required: false + default: 'all' + +runs: + using: "composite" + steps: + - name: Run Simulator Setup Script + shell: bash + env: + PLATFORM: ${{ inputs.platform }} + run: | + "$GITHUB_WORKSPACE/scripts/setup_simulator.sh" "$PLATFORM" diff --git a/.github/workflows/abtesting.yml b/.github/workflows/abtesting.yml index b0f447d5c..4b01f6870 100644 --- a/.github/workflows/abtesting.yml +++ b/.github/workflows/abtesting.yml @@ -36,14 +36,18 @@ env: jobs: spm: name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.os }}) - runs-on: macOS-15 + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: - xcode: ["26.2"] + xcode: ["26.2", "26.4"] os: [iOS, tvOS, macOS, watchOS, catalyst] include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 - os: iOS - device: iPhone 16 # Test runs locally but fails in CI with: # (Underlying Error: lstat of # /Users/runner/Library/Developer/CoreSimulator/Devices/ @@ -52,29 +56,28 @@ jobs: # /Frameworks/GoogleAppMeasurement.framework/GoogleAppMeasurement failed: No such file or directory test: false - os: tvOS - device: Apple TV 4K (3rd generation) (at 1080p) test: true - os: macOS - device: localhost test: true - os: watchOS - device: Apple Watch Series 5 - 44m test: false - os: catalyst - device: localhost test: false # disabled due to a permissions error on launch (OSStatus -54). env: SETUP: abtesting SPM: true DIR: abtesting OS: ${{ matrix.os }} - DEVICE: ${{ matrix.device }} TEST: ${{ matrix.test }} steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: ${{ matrix.os }} - name: Setup run: | gem install xcpretty diff --git a/.github/workflows/analytics.yml b/.github/workflows/analytics.yml index 167668b10..cf1eeb00d 100644 --- a/.github/workflows/analytics.yml +++ b/.github/workflows/analytics.yml @@ -32,34 +32,34 @@ env: jobs: spm: name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.os }}) - runs-on: macOS-15 + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: # TODO: Re-enable when ODM2 catalyst support is investigated - # os: [iOS, catalyst, tvOS, macOS] + # os: [iOS, catalyst, tvOS, macOS] os: [iOS, tvOS, macOS] - xcode: ["26.2"] + xcode: ["26.2", "26.4"] include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 - os: iOS - device: iPhone 16 test: true # TODO: Re-enable when ODM2 catalyst support is investigated # - os: catalyst - # device: localhost # test: false # disabled due to a permissions error on launch (OSStatus -54). - os: tvOS - device: Apple TV 4K (3rd generation) (at 1080p) scheme: AnalyticsExampleTV test: true - os: macOS - device: localhost scheme: AnalyticsExampleMac test: true env: SPM: true OS: ${{ matrix.os }} - DEVICE: ${{ matrix.device }} SCHEME: ${{ matrix.scheme || 'AnalyticsExample' }} DIR: analytics steps: @@ -67,6 +67,10 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: ${{ matrix.os }} - name: Setup run: | cd analytics diff --git a/.github/workflows/authentication.yml b/.github/workflows/authentication.yml index 134ebd409..84e2a79ab 100644 --- a/.github/workflows/authentication.yml +++ b/.github/workflows/authentication.yml @@ -31,20 +31,33 @@ env: jobs: spm: - runs-on: macOS-15 + name: spm (Xcode ${{ matrix.xcode }} - iOS) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: OS: iOS SETUP: authentication SPM: true DIR: authentication - DEVICE: iPhone 16 TEST: false SCHEME: AuthenticationExample steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | gem install xcpretty diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 8e514bdbd..cdb3028b5 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -31,10 +31,19 @@ env: jobs: spm: - runs-on: macOS-15 + name: spm (Xcode ${{ matrix.xcode }} - iOS) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: OS: iOS - DEVICE: iPhone 16 DIR: config SPM: true SCHEME: ConfigExample @@ -43,11 +52,15 @@ jobs: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | cd config ../scripts/install_prereqs/config.sh - xcrun simctl boot "iPhone 16" + xcrun simctl boot "Firebase-iPhone-15-Pro" - name: Build Swift run: ./scripts/test.sh diff --git a/.github/workflows/crashlytics.yml b/.github/workflows/crashlytics.yml index 8fca3a785..5fa9902d4 100644 --- a/.github/workflows/crashlytics.yml +++ b/.github/workflows/crashlytics.yml @@ -32,36 +32,40 @@ env: jobs: spm: name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.os }}) - runs-on: macOS-15 + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: - xcode: ["26.2"] + xcode: ["26.2", "26.4"] os: [iOS, tvOS, macOS, watchOS] include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 - os: iOS - device: iPhone 16 test: false # flaky - os: tvOS - device: Apple TV 4K (3rd generation) (at 1080p) test: true - os: macOS - device: localhost test: true - os: watchOS - device: Apple Watch Series 5 - 44m test: false env: SETUP: crashlytics SPM: true DIR: crashlytics OS: ${{ matrix.os }} - DEVICE: ${{ matrix.device }} TEST: ${{ matrix.test }} steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: ${{ matrix.os }} - name: Setup run: | gem install xcpretty diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml index 0a9502d0e..95eb00272 100644 --- a/.github/workflows/database.yml +++ b/.github/workflows/database.yml @@ -31,20 +31,32 @@ env: jobs: spm-buildonly: - name: spm (non-SwiftUI) - runs-on: macOS-15 + name: spm (Xcode ${{ matrix.xcode }} - non-SwiftUI) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: OS: iOS SPM: true DIR: database - DEVICE: iPhone 16 TEST: false SCHEME: DatabaseExample steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | gem install xcpretty @@ -55,33 +67,38 @@ jobs: spm: name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.os }}) - runs-on: macOS-15 + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: - xcode: ["26.2"] + xcode: ["26.2", "26.4"] os: [iOS, tvOS, macOS] include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 - os: iOS - device: iPhone 16 test: false - os: tvOS - device: Apple TV 4K (3rd generation) (at 1080p) test: true - os: macOS - device: localhost test: false # flaky macOS UITest: UITests.testStaticSignUpView() sometimes fails env: SETUP: database SPM: true DIR: database/DatabaseExampleSwiftUI/DatabaseExample OS: ${{ matrix.os }} - DEVICE: ${{ matrix.device }} TEST: ${{ matrix.test }} steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: ${{ matrix.os }} - name: Setup run: | gem install xcpretty diff --git a/.github/workflows/firebaseai.yml b/.github/workflows/firebaseai.yml index b5cb9e06a..0118dc46e 100644 --- a/.github/workflows/firebaseai.yml +++ b/.github/workflows/firebaseai.yml @@ -22,45 +22,36 @@ env: jobs: spm: - name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.platform }}) + name: spm (Xcode ${{ matrix.xcode }} - iOS) + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: + xcode: ["26.2", "26.4"] include: - - os: macos-26 - xcode: "26.6" - platform: iOS - device: iPhone 17 Pro - ios_version: "26.5" - - os: macos-15 - xcode: "26.2" - platform: iOS - device: iPhone 16 - ios_version: "18.5" - runs-on: ${{ matrix.os }} + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SETUP: firebaseai SPM: true DIR: firebaseai - OS: ${{ matrix.platform }} - VERSION: ${{ matrix.ios_version }} - DEVICE: ${{ matrix.device }} + OS: iOS TEST: false steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - - name: Install simulators in case they are missing. - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3 + - name: Setup simulator + uses: ./.github/actions/setup_simulator with: - timeout_minutes: 15 - max_attempts: 5 - retry_wait_seconds: 120 - command: sudo xcodebuild -downloadPlatform iOS + platform: iOS - name: Setup run: | gem install xcpretty - name: Placeholder GoogleService-Info.plist good enough for build only testing. run: cp ./mock-GoogleService-Info.plist ./firebaseai/GoogleService-Info.plist - - name: Build and Test SwiftUI (${{ matrix.platform }}) + - name: Build and Test SwiftUI (iOS) run: ./scripts/test.sh diff --git a/.github/workflows/firestore.yml b/.github/workflows/firestore.yml index e7039575b..13ed7aff3 100644 --- a/.github/workflows/firestore.yml +++ b/.github/workflows/firestore.yml @@ -31,19 +31,35 @@ env: jobs: spm: - runs-on: macos-26 + name: spm (Xcode ${{ matrix.xcode }} - iOS) + runs-on: ${{ matrix.runner }} + # TODO: Remove continue-on-error once firebase-ios-sdk 13.2.0 is released + # with the Xcode 26.2 package traits workaround (firebase/firebase-ios-sdk#16944). + continue-on-error: ${{ matrix.xcode == '26.2' }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SPM: true OS: iOS DIR: firestore - DEVICE: iPhone 17 Pro TEST: false SCHEME: FirestoreExample steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.4.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | cd firestore diff --git a/.github/workflows/functions.yml b/.github/workflows/functions.yml index ad70b47b5..5c894d3c1 100644 --- a/.github/workflows/functions.yml +++ b/.github/workflows/functions.yml @@ -32,30 +32,32 @@ env: jobs: spm: name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.os }}) - runs-on: macOS-15 + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: - xcode: ["26.2"] + xcode: ["26.2", "26.4"] os: [iOS, tvOS, macOS] include: - - os: iOS - device: iPhone 16 - - os: tvOS - device: Apple TV 4K (3rd generation) (at 1080p) - - os: macOS - device: localhost + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SETUP: functions SPM: true DIR: functions/FunctionsExample OS: ${{ matrix.os }} - DEVICE: ${{ matrix.device }} TEST: false steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: ${{ matrix.os }} - name: Setup run: | gem install xcpretty diff --git a/.github/workflows/inappmessaging.yml b/.github/workflows/inappmessaging.yml index 422ce2904..214414132 100644 --- a/.github/workflows/inappmessaging.yml +++ b/.github/workflows/inappmessaging.yml @@ -31,18 +31,31 @@ env: jobs: spm: - runs-on: macOS-15 + name: spm (Xcode ${{ matrix.xcode }} - iOS) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SPM: true DIR: inappmessaging OS: iOS - DEVICE: iPhone 16 TEST: false steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | cd inappmessaging diff --git a/.github/workflows/installations.yml b/.github/workflows/installations.yml index 1e18d74ba..6c713e9d4 100644 --- a/.github/workflows/installations.yml +++ b/.github/workflows/installations.yml @@ -31,18 +31,31 @@ env: jobs: spm: - runs-on: macOS-15 + name: spm (Xcode ${{ matrix.xcode }} - iOS) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SPM: true OS: iOS - DEVICE: iPhone 16 TEST: true DIR: installations steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | cd installations diff --git a/.github/workflows/messaging.yml b/.github/workflows/messaging.yml index 68e29f7b9..3cea449eb 100644 --- a/.github/workflows/messaging.yml +++ b/.github/workflows/messaging.yml @@ -31,18 +31,31 @@ env: jobs: spm: - runs-on: macOS-15 + name: spm (Xcode ${{ matrix.xcode }} - iOS) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SPM: true OS: iOS - DEVICE: iPhone 16 TEST: false DIR: messaging steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | cd messaging diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index c67b2a58b..c83de0392 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -31,12 +31,20 @@ env: jobs: spm-buildonly: - name: spm - runs-on: macOS-15 + name: spm (Xcode ${{ matrix.xcode }}) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + xcode: ["26.2", "26.4"] + include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SPM: true OS: iOS - DEVICE: iPhone 16 TEST: false DIR: performance SCHEME: PerformanceExample (iOS) @@ -44,7 +52,11 @@ jobs: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode - run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: iOS - name: Setup run: | cd performance @@ -52,21 +64,24 @@ jobs: ../scripts/install_prereqs/performance.sh - name: Build Swift run: ./scripts/test.sh - + spm: name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.os }}) - runs-on: macOS-15 + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: - xcode: ["26.2"] + xcode: ["26.2", "26.4"] os: [iOS, tvOS] include: + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 - os: iOS - device: iPhone 16 test: false scheme: PerformanceExample (iOS) - os: tvOS - device: Apple TV 4K (3rd generation) (at 1080p) test: false scheme: PerformanceExample (tvOS) env: @@ -74,7 +89,6 @@ jobs: SPM: true DIR: performance OS: ${{ matrix.os }} - DEVICE: ${{ matrix.device }} TEST: ${{ matrix.test }} SCHEME: ${{ matrix.scheme }} steps: @@ -82,6 +96,10 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: ${{ matrix.os }} - name: Setup run: | gem install xcpretty diff --git a/.github/workflows/storage.yml b/.github/workflows/storage.yml index ec200b06b..13a46964a 100644 --- a/.github/workflows/storage.yml +++ b/.github/workflows/storage.yml @@ -32,30 +32,32 @@ env: jobs: spm: name: spm (Xcode ${{ matrix.xcode }} - ${{ matrix.os }}) - runs-on: macOS-15 + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: - xcode: ["26.2"] + xcode: ["26.2", "26.4"] os: [iOS, tvOS, macOS] include: - - os: iOS - device: iPhone 16 - - os: tvOS - device: Apple TV 4K (3rd generation) (at 1080p) - - os: macOS - device: localhost + - xcode: "26.2" + runner: macos-15 + - xcode: "26.4" + runner: macos-26 env: SETUP: storage SPM: true DIR: storage OS: ${{ matrix.os }} - DEVICE: ${{ matrix.device }} TEST: false steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Setup simulator + uses: ./.github/actions/setup_simulator + with: + platform: ${{ matrix.os }} - name: Setup run: | gem install xcpretty diff --git a/scripts/setup_simulator.sh b/scripts/setup_simulator.sh new file mode 100755 index 000000000..fa049766b --- /dev/null +++ b/scripts/setup_simulator.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +# Copyright 2026 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. + +# TODO: Temporary local copy of firebase/firebase-ios-sdk/scripts/setup_simulator.sh +# (with SDK-major runtime matching and `macOS|catalyst` no-op support). +# Consolidate once upstream `firebase-ios-sdk` supports cross-repo composite +# action invocation. + +set -euo pipefail + +PLATFORM="${1:-all}" + +echo " Active Xcode Info:" +xcodebuild -version +echo " Installed Simulator Runtimes:" +xcrun simctl list runtimes + +get_runtime() { + local platform_prefix="$1" + local sdk_name="" + case "$platform_prefix" in + iOS) sdk_name="iphonesimulator" ;; + tvOS) sdk_name="appletvsimulator" ;; + watchOS) sdk_name="watchsimulator" ;; + visionOS) sdk_name="xrsimulator" ;; + esac + + local target_major="" + if [[ -n "$sdk_name" ]]; then + local sdk_ver + sdk_ver=$(xcrun --sdk "$sdk_name" --show-sdk-version 2>/dev/null || true) + if [[ -n "$sdk_ver" ]]; then + target_major="${sdk_ver%%.*}" + fi + fi + + local runtime="" + if [[ -n "$target_major" ]]; then + runtime=$(xcrun simctl list runtimes available | grep "^${platform_prefix} ${target_major}\." | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) + fi + + if [[ -z "$runtime" ]]; then + runtime=$(xcrun simctl list runtimes available | grep "^${platform_prefix}" | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) + fi + + echo "$runtime" +} + +create_sim() { + local sim_name="$1" + local runtime="$2" + shift 2 + local device_types=("$@") + + if [[ -z "$runtime" ]]; then + echo "âš ī¸ Warning: No available runtime found for $sim_name. Skipping creation." + return 0 + fi + + if xcrun simctl list devices available | grep -q "${sim_name} ("; then + echo "✅ Simulator '$sim_name' already exists and is available." + else + local created=false + for device_type in "${device_types[@]}"; do + echo "📲 Attempting to create '$sim_name' with type '$device_type' and runtime '$runtime'..." + if xcrun simctl create "$sim_name" "$device_type" "$runtime" 2>/dev/null; then + echo "✅ Successfully created '$sim_name' using '$device_type'." + created=true + break + else + echo "âš ī¸ Device type '$device_type' is incompatible with '$runtime' or unavailable." + fi + done + + if [[ "$created" = false ]]; then + echo "❌ Failed to create simulator '$sim_name' with any provided device types." + return 1 + fi + fi +} + +case "$PLATFORM" in + iOS) + create_sim "Firebase-iPhone-15-Pro" "$(get_runtime iOS)" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-Duo" + ;; + tvOS) + create_sim "Firebase-Apple-TV-4K-Gen-2" "$(get_runtime tvOS)" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-1080p" + ;; + watchOS) + create_sim "Firebase-Apple-Watch-Ultra-2" "$(get_runtime watchOS)" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-2-49mm" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-3-49mm" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-4-49mm" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-3-44mm" + ;; + visionOS) + create_sim "Firebase-Apple-Vision-Pro" "$(get_runtime visionOS)" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro" + ;; + macOS|catalyst) + echo "â„šī¸ Platform '$PLATFORM' does not require a simulator." + ;; + all) + create_sim "Firebase-iPhone-15-Pro" "$(get_runtime iOS)" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro" \ + "com.apple.CoreSimulator.SimDeviceType.iPhone-Duo" + create_sim "Firebase-Apple-TV-4K-Gen-2" "$(get_runtime tvOS)" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-1080p" + create_sim "Firebase-Apple-Watch-Ultra-2" "$(get_runtime watchOS)" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-2-49mm" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-3-49mm" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-4-49mm" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-3-44mm" + create_sim "Firebase-Apple-Vision-Pro" "$(get_runtime visionOS)" \ + "com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro" + ;; + *) + echo "❌ Unknown platform: $PLATFORM" + exit 1 + ;; +esac diff --git a/scripts/test.sh b/scripts/test.sh index 9da46ae9e..d37832248 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -38,15 +38,26 @@ if [[ -z "${OS:-}" ]]; then OS=iOS echo "Defaulting to OS=$OS" fi -if [[ -z "${DEVICE:-}" && "$OS" == "iOS" ]]; then - DEVICE="iPhone 17 Pro" - echo "Defaulting to DEVICE=$DEVICE" +if [[ -z "${DEVICE:-}" ]]; then + case "$OS" in + iOS) DEVICE="Firebase-iPhone-15-Pro" ;; + tvOS) DEVICE="Firebase-Apple-TV-4K-Gen-2" ;; + watchOS) DEVICE="Firebase-Apple-Watch-Ultra-2" ;; + macOS|catalyst) DEVICE="localhost" ;; + esac + echo "Defaulting to DEVICE=${DEVICE:-}" fi if [[ -z "${TEST:-}" ]]; then TEST=true echo "Defaulting to TEST=$TEST" fi +if [[ "$OS" == "iOS" || "$OS" == "tvOS" || "$OS" == "watchOS" ]]; then + if ! xcrun simctl list devices available | grep -q "${DEVICE} ("; then + ./scripts/setup_simulator.sh "$OS" + fi +fi + # Set have_secrets to true or false. have_secrets=false # shellcheck disable=SC1091