Skip to content

test: add shared hosted-tests project for SPM test suites - #17135

Open
paulb777 wants to merge 2 commits into
mainfrom
pb-spm-hosted-tests
Open

paulb777 wants to merge 2 commits into
mainfrom
pb-spm-hosted-tests

Conversation

@paulb777

@paulb777 paulb777 commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Discussion

Some SDK tests need an app process: keychain access, UIApplication.sharedApplication with a delegate, or a main bundle. Swift Package Manager test bundles don't have these, so these tests run today only through CocoaPods test specs or pod gen workspaces. This PR adds one shared Xcode project for them, so each SDK doesn't need its own host app. It has no SDK tests yet; the Installations integration tests from #17114 are planned as the first.

  • IntegrationTesting/HostedTests/HostedTests.xcodeproj has a blank iOS/tvOS host app, FirebaseTestHost (scene-based main.m, links no Firebase code), and an XCLocalSwiftPackageReference to ../... Source folders are synchronized folders, so adding test files doesn't change project.pbxproj.
  • The HostSmokeTests target and shared scheme check what the host provides: a SecItemAdd/SecItemCopyMatching/SecItemDelete round-trip with a unique service name, UIApplication.shared.delegate being the host's FIRTestHostAppDelegate, a GoogleService-Info.plist (fake values) copied into the test bundle by a run script phase and readable with FirebaseOptions(contentsOfFile:) while Bundle.main has none, and FirebaseCore linked into the test bundle (Bundle(for: FirebaseApp.self) is the test bundle).
  • The run script phase copies TestConfig/$(TARGET_NAME)/GoogleService-Info.plist into the test bundle and removes a stale copy when the file is missing (the approach from test(installations): run the integration tests in an SPM test app #17114), so SDK targets can reuse it unchanged. .gitignore ignores decrypted plists under TestConfig, except the smoke test's fake one.
  • scripts/build.sh gets generic HostedTests-<scheme> cases (test by default, plus build, build-for-testing, and test-without-building), so SDK schemes need no new cases. Example: scripts/build.sh HostedTests-HostSmokeTests tvOS.
  • New infra.hosted_tests.yml runs HostSmokeTests on iOS and tvOS on macos-26 with Xcode 26.4, for PRs that change IntegrationTesting/HostedTests/**, scripts/build.sh, or the workflow, plus nightly. It's a standalone job instead of _build.yml, because _build.yml installs Ruby and Bundler for this method and doesn't upload xcresult bundles.
  • IntegrationTesting/HostedTests/README.md explains how an SDK adds a <SDK>HostedTests target and scheme, secrets, CI path filters, keychain hygiene, when to add another host target, and to try tests without a host first.

Not changed / known limitations

  • No SDK tests move here in this PR.
  • The project's iOS and tvOS deployment target is 17.0 (XCTest needs 17.0 to link), so hosted tests aren't compiled at the SDKs' minimum deployment targets.
  • macOS, watchOS, visionOS, and Catalyst aren't supported by the host.
  • scripts/repo.sh test still runs Firebase<SDK>Integration cases; the README uses scripts/repo.sh decrypt followed by scripts/build.sh for hosted schemes.
  • scripts/build.sh changes trigger other workflows' path filters, including sdk.ai.yml's live-backend jobs.

Testing

  • Xcode 27.2: xcodebuild test -project IntegrationTesting/HostedTests/HostedTests.xcodeproj -scheme HostSmokeTests passed 4 of 4 tests on iPhone 17 (iOS 27.2) and on Apple TV 4K (4th generation) (tvOS 27.2) simulators.
  • Xcode 26.5: the same command passed 4 of 4 tests on iPhone 17 (iOS 26.5) and Apple TV 4K (3rd generation) (tvOS 26.5) simulators.
  • Without a host (same scheme with TEST_HOST= on iOS 27.2), testKeychainRoundTrip failed with -34018 (errSecMissingEntitlement) and testSharedApplicationHasHostDelegate found no delegate, so these checks detect a missing host.
  • No compiler warnings from main.m or HostSmokeTests.swift in the four test runs. The project's own targets build with warnings as errors; Firebase package targets don't.
  • scripts/style.sh reports the changed files as clean (clang-format 23.1.0, swiftformat 0.55.5). zizmor reports no findings for the new workflow.
  • scripts/build.sh HostedTests-HostSmokeTests iOS wasn't run to completion locally: the local Firebase-iPhone-15-Pro simulator has iOS 27.0, which Xcode 27.2 doesn't match for this destination. DRY_RUN=1 shows the expected xcodebuild commands for test, build, build-for-testing, and test-without-building. The new workflow runs it on CI.

API Changes

None.

#no-changelog

This PR was prepared with AI assistance.

Add IntegrationTesting/HostedTests/HostedTests.xcodeproj, a project for
SDK test suites that need an app process (keychain, UIApplication, a
main bundle), which Swift Package Manager test bundles don't have. It
has a blank iOS/tvOS host app, FirebaseTestHost, that links no Firebase
code, and a local package reference to the repo's Package.swift.

The HostSmokeTests target checks what the host provides: a keychain
round-trip, the host's app delegate, a GoogleService-Info.plist copied
into the test bundle by a build phase, and FirebaseCore linked into the
test bundle rather than the host.

Add generic `HostedTests-<scheme>` cases to scripts/build.sh, the
infra.hosted_tests workflow that runs HostSmokeTests on iOS and tvOS,
and a README with the steps for adding an SDK's tests.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@paulb777

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a hosted testing framework under IntegrationTesting/HostedTests to run SDK test suites requiring an app process, including a blank host app FirebaseTestHost, a smoke test suite HostSmokeTests, and updates to scripts/build.sh to support these schemes. The review feedback recommends dynamically handling the test-without-building action in scripts/build.sh to support standard CI/CD workflows, and correcting the API reference in the README from UIApplication.sharedApplication to UIApplication.shared.

Comment thread scripts/build.sh Resolved
Add a HostedTests-*-test-without-building case to scripts/build.sh so CI can split build-for-testing and test-without-building, and use UIApplication.shared in the README.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant