chore: sync upstream capawesome-team/capacitor-firebase e8336a2b

Merged
RI
1d ago
+9301-2976

What

  • Merge upstream main at e8336a2b916c7d4a3f824850470bc26d47430869
  • Set .github/upstream-sync.json lastIntegratedUpstreamSha to e8336a2b916c7d4a3f824850470bc26d47430869
  • Port analytics, authentication, firestore, and functions native restructures plus analytics, firestore, functions, and performance fixes under Cap-go package paths

Why

Scheduled upstream sync on issue #32 failed with merge conflicts. This PR advances the fork to the current upstream head and records the marker so scheduled sync can skip until upstream moves again.

How

  • Merged upstream commit e8336a2b (same approach as PR #31 for issue #30)
  • Kept Cap-go workflows, templates, @capgo/* package names, CapgoCapacitorFirebase* podspecs and SPM names, README promo sections, and bun-based root tooling
  • Rejected upstream .changeset/, package-lock.json, upstream .github/workflows, and packages/app-check/ (Cap-go uses packages/appcheck/)
  • Rewrote Java from io.capawesome to app.capgo.capacitor.firebase.* and dropped duplicate upstream podspecs where Cap-go already ships Capgo* names
  • Restored Cap-go getPluginVersion on Android plugins and analytics Android getSessionId after porting upstream logic

Upstream commits integrated (since 15c2107d)

SHAChange
a7bf8081Firestore: reject invalid arguments on iOS instead of crashing
b1fb7762Authentication native restructure (part 1)
26a1c30eFirestore: return results through callbacks in all methods
8a9498a4Authentication: appName option for named Firebase app
7ca7110eFirestore: more invalid argument rejection on iOS
a436b9feFunctions: error codes on Android and iOS, invalid URL on iOS
d271c908Functions native restructure
8414304dAnalytics: setConsent, setSessionTimeoutDuration, logEvent on Android
d481aefaAnalytics native restructure
e8336a2bPerformance: getAttributes, startTrace, putMetric

Conflicts resolved

AreaResolution
.github/Kept Cap-go issue templates, PR template, and Cap-go workflows; removed upstream workflow files reintroduced by merge
Root metadataKept Cap-go package.json, README branding; removed upstream package-lock.json and .changeset/
Package README, CHANGELOG, package.jsonKept Cap-go versions and @capgo/* names; kept dependency bumps where upstream only changed versions
Podspecs / Package.swiftKept CapgoCapacitorFirebase*; removed upstream CapacitorFirebase* duplicates
Native JavaTook upstream implementation under app/capgo/... paths
Native iOS / TSTook upstream behavior; preserved Cap-go-only APIs such as getPluginVersion where applicable

Testing

  • bun install
  • bun run fmt
  • bun run lint
  • bun run build
  • bun run verify:web

Not Tested

  • Full verify:android and verify:ios on this VM (no Android SDK, no macOS). CI runs platform builds.

Refs #32

Open in Web Open in Cursor 

Mac verification (MacinCloud, over ssh)

Host: macOS 15.7.4, Xcode 26.3, simulator iPhone 16 Pro (iOS 26.3), throwaway sim created for this run and deleted after. Own workdir ~/tori-fb33, removed after the run. Branch built at ab9b9391 (main merged in), plus the fix in c997ca17.

  1. Plugin builds, same as CI verify:ios, for all 11 packages:
    cd packages/<pkg>/ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS
    Result: BUILD SUCCEEDED for analytics, app, appcheck, authentication, crashlytics, firestore, functions, messaging, performance, remote-config, storage. authentication and functions rebuilt from clean after the fix: BUILD SUCCEEDED.
  2. Run: Capacitor 8 app (SPM, npx cap add ios --packagemanager SPM) with all 11 packages installed from npm pack tarballs of this branch, a dummy GoogleService-Info.plist (fake values, no real project), built with xcodebuild -sdk iphonesimulator, installed and launched with xcrun simctl launch --console-pty. The page calls getPluginVersion() on every plugin and FirebaseApp.getName().
    • Before the fix: Error: Plugin FirebaseAuthentication does not respond to method call "getPluginVersion" (the sync dropped the method in authentication and functions while pluginMethods still declares it). Fixed in c997ca17.
    • After the fix, app log:
      TO JS {"version":"8.6.2"}   FirebaseAnalytics
      TO JS {"version":"8.6.2"}   FirebaseApp
      TO JS {"version":"8.7.0"}   FirebaseAppCheck
      TO JS {"version":"8.6.3"}   FirebaseAuthentication
      TO JS {"version":"8.6.3"}   FirebaseCrashlytics
      TO JS {"version":"8.6.1"}   FirebaseFirestore
      TO JS {"version":"8.6.2"}   FirebaseFunctions
      TO JS {"version":"8.6.3"}   FirebaseMessaging
      TO JS {"version":"8.6.2"}   FirebasePerformance
      TO JS {"version":"8.6.2"}   FirebaseRemoteConfig
      TO JS {"version":"8.6.2"}   FirebaseStorage
      TO JS {"name":"__FIRAPP_DEFAULT"}
      
      Screen: SMOKE 11/11, no crash.
    • Note: app and firestore report stale native versions because their Swift line is private let pluginVersion = "..." (no : String), which the release bumper regex does not match. Same on main, not caused by this PR.

Mac verification for the not-configured guards and XCTests (ssh mac20)

Run on 2026-11-28 at the tree of HEAD 00c5c37339fd9a8153bcd41d14714f3e73d55546 (the committed diff applied on top of 9fd85969). Host: macOS 27.0.1, Xcode 27.2, simulator iPhone 17 Pro (iOS 27.0), over ssh mac20. Workdirs ~/tori-tests/fb33-r3 and ~/tori-tests/fb33-r3app (sourced ~/tori-tests/env.sh), removed after the run together with the throwaway simulators. No customer builder jobs or profiles were touched. On this Xcode 27 host a local-only Podfile post_install (not in the PR) deleted pod IPHONEOS_DEPLOYMENT_TARGET.

What changed in this round (Codex thread on load() leaving implementation nil):

  • Every bridged method of analytics (14), appcheck (3), authentication (54), firestore (21), functions (3), performance (11) and storage (8) now starts with guard let implementation = implementation else { call.reject(errorFirebaseNotConfigured); return }. These are the seven packages whose load() can leave implementation nil. errorFirebaseNotConfigured was added to analytics, authentication and firestore. Upstream logic is otherwise unchanged.
  • app, crashlytics, messaging and remote-config always create implementation in load(), so their optional chains cannot skip a completion; they are unchanged.
  • The stale echo PluginTests of those seven packages were replaced by real XCTests (*UnconfiguredTests) that build the plugin with no plist and no default FirebaseApp, call the bridged methods and assert each one rejects with the not-configured message and never resolves.
  • CI: verify:ios of those packages now calls scripts/ios-test.mjs, which runs xcodebuild test on one iOS Simulator, instead of the generic device compile. So the existing Test iOS job runs the XCTests. No .github change, no new secrets.
  1. XCTests, pod install then IOS_TEST_UDID=<sim> node ../../scripts/ios-test.mjs per package, iOS 27.0 simulator:

    • analytics: 4 tests, 0 failures (FirebaseAnalyticsUnconfiguredTests, includes getAppInstanceId and setEnabled)
    • authentication: 5 tests, 0 failures (FirebaseAuthenticationUnconfiguredTests.testGetCurrentUserRejectsWhenFirebaseIsNotConfigured, getIdToken, signOut, signInAnonymously, deleteUser)
    • firestore: 4 tests, 0 failures
    • functions: 3 tests, 0 failures
    • performance: 3 tests, 0 failures
    • storage: 3 tests, 0 failures
    • appcheck: 3 tests, 0 failures
      All report ** TEST SUCCEEDED **. The authentication and firestore tests do not call load(), because it reads the plugin config from the Capacitor bridge, which a unit test does not have; the implementation is nil in that case just as after load() without the plist. The real load() path is covered by the app run below.
  2. Unconfigured Capacitor 8 app (SPM, seven plugins, no GoogleService-Info.plist), built with xcodebuild -sdk iphonesimulator, launched with xcrun simctl launch --console-pty, every JS call raced against an 8 second hang timer. All 22 promise calls rejected, none hung:

    TORI auth.getCurrentUser REJECT_OK Firebase is not configured: GoogleService-Info.plist is missing from the app bundle.
    TORI auth.getIdToken / signOut / signInAnonymously / signInWithEmailAndPassword / sendPasswordResetEmail / deleteUser REJECT_OK (same message)
    TORI analytics.getAppInstanceId / setEnabled / logEvent / setUserId REJECT_OK (same message)
    TORI firestore.getDocument / terminate / removeAllListeners REJECT_OK (same message)
    TORI functions.callByName / callByUrl REJECT_OK (same message)
    TORI performance.startTrace / isEnabled / setEnabled REJECT_OK (same message)
    TORI storage.deleteFile / listFiles REJECT_OK (same message)
    TORI appcheck.getToken REJECT_OK (same message)
    TORI DONE
    

    storage.downloadFile takes a callback, so its promise resolves with a callback id; the native log shows To Native -> FirebaseStorage downloadFile followed immediately by ERROR MESSAGE: Firebase is not configured: GoogleService-Info.plist is missing from the app bundle.

  3. Configured app with a dummy GoogleService-Info.plist (fake values, no real project), same flow, to check the guards pass through:

    TORI auth.getCurrentUser OK {"user":null}
    TORI performance.isEnabled OK {"enabled":true}
    TORI firestore.removeAllListeners OK
    TORI functions.version OK {"version":"8.6.2"}
    TORI storage.version OK {"version":"8.6.2"}
    

    No crash.

  4. CI note (Test iOS, same job, no workflow change): at 00c5c373 the job hit the existing 45-minute cap because appcheck ran both its SPM generic compile and a CocoaPods simulator test. c6f4d6ad keeps appcheck `verify:ios` as the original SPM generic build. The unconfigured XCTests still run in Test iOS for analytics, authentication, firestore, functions, performance and storage. Appcheck XCTests remain in the tree and were run on this Mac (3 tests, 0 failures).

Test iOS timeout (c6f4d6ad) and the speed fix

Test iOS run 46144296315 at c6f4d6ad was cancelled at the existing 45-minute job cap (12:22:04Z to 13:07:32Z). Every unconfigured XCTest that started had already passed (storage 3, firestore 4, analytics 4, authentication 5 including getCurrentUser, functions 3, performance 3). The job was cut during the last two generic packages (app-check and remote-config, about 2 minutes of work left).

Measured from the cancelled log vs the last green generic-only run at 9fd85969 (Test iOS 39m9s, 10:00Z to 10:39Z):

Step9fd85969 (generic only)c6f4d6ad (generic + XCTest)
CocoaPods install6m21s5m25s
SPM install (11 packages, serial)8m36s7m17s
verify:ios build24m01s32m15s then cancelled
Total Test iOS39m9s45m28s cancelled

The 24m generic build plus XCTests almost fit. Firestore is about 15 minutes either as a generic compile or as xcodebuild test (the tests themselves take ~0.02s; the cost is compiling Firestore). The extra time was the first simulator test package (storage, 7.7 minutes including first sim boot and iphonesimulator compile, vs 1 to 2 minutes for a first generic package) plus a bit more on the other test packages. The job was 1 to 3 minutes short.

What this commit changes (package scripts only, no .github file, no timeout change):

  • affected:ios:spm:install and ios:spm:install now use turbo --concurrency=4 instead of 1. The SPM step is 11 serial swift package resolve calls (about 30 to 50s each, 7 to 8.5 minutes total). Four-way resolve should cut that to roughly 2 to 3 minutes and buy back more than the missing 2 minutes, with margin.
  • scripts/ios-test.mjs now pins arch=arm64 and ONLY_ACTIVE_ARCH=YES so the sim build does not also compile x86_64, disables the compiler index store, skips simulator code signing, sets IPHONEOS_DEPLOYMENT_TARGET=15.0 (needed so pod targets below iOS 15 build on Xcode 27; Capacitor 8 already requires iOS 15), reuses a booted iPhone simulator when one exists, and logs boot vs xcodebuild times. verify:ios still runs xcodebuild test once per package (no extra generic compile).

Unconfigured XCTests still run in the existing Test iOS job for analytics (4), authentication (5, including getCurrentUser), firestore (4), functions (3), performance (3) and storage (3). appcheck stays on the SPM generic compile; its XCTests stay in the tree and were already run on mac20 in the previous round.

Mac verification of the timeout fix (ssh mac20)

Run on 2026-11-28 at the tree of this commit, over ssh mac20. Host: macOS 27, Xcode 27.2 (no Xcode 16.4 on this Mac), throwaway simulator tori-fb33-ios (iPhone 17 Pro, iOS 26.5). Workdir ~/tori-tests/fb33-ios, sourced ~/tori-tests/env.sh. Own DerivedData under ~/tori-tests/fb33-dd. Workdir, DerivedData, log, and the throwaway simulator were removed after the run. No customer builder jobs, profiles, or keychains were touched. No sudo.

pod install then IOS_TEST_UDID=<tori-fb33-ios> IOS_TEST_DERIVED_DATA=~/tori-tests/fb33-dd node ../../scripts/ios-test.mjs for each package, after bun i at the repo root:

PackageXCTestsResultxcodebuild test time
storage3TEST SUCCEEDED10.1s
functions3TEST SUCCEEDED10.4s
performance3TEST SUCCEEDED19.9s
analytics4TEST SUCCEEDED9.4s
authentication5, including testGetCurrentUserRejectsWhenFirebaseIsNotConfiguredTEST SUCCEEDED13.7s
firestore4TEST SUCCEEDED244.2s (~4m4s)

These Mac times are not CI times (different Xcode and a warmer machine). They confirm the new ios-test flags still run Jose's unconfigured path, including authentication getCurrentUser. On this Xcode 27 host, IPHONEOS_DEPLOYMENT_TARGET=15.0 was required so GoogleUtilities and other pods that declare iOS 12 still compile; CI uses Xcode 16.4, where that is harmless.

Test iOS timeout, round 2 (a564e682 to a30e23f0)

Run 46150646273 at a564e682 was also cancelled at the existing 45-minute cap (13:38:53Z to 14:24:24Z), with every XCTest that ran passing. Measured from its log:

Stepc6f4d6ada564e682
CocoaPods install5m25s4m33s
SPM install7m17s (serial)4m30s (concurrency 4)
firestore verify:ios (CocoaPods sim test)14m33s21m33s (incl. 91s first sim boot; xcodebuild test 1171s)
other packagesabout 17mabout 14m, cut before crashlytics and analytics

So concurrency 4 saved about 3 minutes on SPM, but firestore alone is 14 to 21 minutes on this runner: its CocoaPods workspace compiles gRPC, BoringSSL and abseil from source. The 4 firestore tests themselves take 0.01s.

Fix in a30e23f0 (no .github change, no timeout change):

  • packages/firestore/Package.swift gets a testTarget on ios/PluginTests (same pattern appcheck already ships; ios/PluginTests is not in the npm files, and SwiftPM does not load test targets of dependencies).
  • FirebaseFirestoreTests.swift imports CapgoFirebaseFirestorePlugin under SwiftPM and Plugin under the Xcode project.
  • firestore verify:ios still runs pod install (podspec resolution), then ios-test.mjs --spm CapgoCapacitorFirebaseFirestore, which runs xcodebuild test on the package scheme. Firestore, gRPC and abseil then come in as prebuilt SPM binaries.
  • Trade-off: firestore plugin sources are now compiled in CI through SwiftPM instead of the CocoaPods workspace (same Swift sources; the podspec still resolves).

Unconfigured XCTests that run in Test iOS: analytics 4, authentication 5 (incl. getCurrentUser), firestore 4 (SwiftPM), functions 3, performance 3, storage 3.

Mac20 cold check at a30e23f0 (fresh workdir ~/tori-tests/fb33-r5, fresh DerivedData, fresh simulator tori-fb33-r5 iPhone 17 Pro iOS 26.5, Xcode 27.2, bun i then bun run verify:ios per package; all removed after, no sudo, no customer jobs touched):

  • firestore via SwiftPM: 4 tests, 0 failures, TEST SUCCEEDED, xcodebuild test 139s cold (CocoaPods path was 244s warm on the same Mac, 1171s in CI).
  • storage via CocoaPods (unchanged path): 3 tests, 0 failures, TEST SUCCEEDED, 65s.

Follow-up at a0143f9: run 46155430709 at a30e23f0 failed in the SPM install step, because turbo --concurrency=4 made parallel swift package resolve calls race on the shared SwiftPM artifact cache (maintenance.lock, invalid archive). SPM install is back to --concurrency=1 (the a564e682 change is undone). The time budget now comes only from the firestore SwiftPM test.

Test iOS timeout, round 3 (a0143f9 to ee37372d)

Run 46156017676 at a0143f9 (14:42:19Z to 15:27:49Z) was cancelled by the 45-minute cap while on its last package, with every XCTest passing. Firestore through SwiftPM now takes about 5 minutes instead of 14 to 21 (xcodebuild test 235s). The remaining cost was a slow runner (first simulator boot 97s, performance 523s vs 46 to 88s in earlier runs) plus the pre-build steps: CocoaPods install 5m48s and serial SPM install 8m13s.

Fix in ee37372d (package scripts only, no .github change, no timeout change): only appcheck and firestore are built through SwiftPM in verify:ios, and they resolve their own dependencies there. For the other nine packages ios:spm:install was 9 serial swift package resolve calls (about 40s each) over the same dependency graph. They now run swift package dump-package, which still fails on a broken Package.swift (checked on mac20: exit 1 on a broken manifest, 1 to 4s per package, versus 24s for a resolve with a warm cache). Expected saving: about 6 minutes of the SPM step. Trade-off: those nine packages no longer resolve remote dependencies in the standalone step; the guard_swiftpm_version job still pins capacitor-swift-pm.

All unconfigured XCTests still run in Test iOS: analytics 4, authentication 5, firestore 4 (SwiftPM), functions 3, performance 3, storage 3.

Mac verification at 0afe7f56 (ssh mac20)

Run on 2026-11-28 over ssh mac20. Host: macOS 27, Xcode 27.2. Fresh clone in ~/tori-tests/fb33-r8, sourced ~/tori-tests/env.sh. Throwaway simulator tori-fb33-r8 (iPhone 17 Pro, iOS 26.5). Isolated DerivedData per package under ~/tori-tests/fb33-r8-dd-<package> so CocoaPods packages that share the Plugin scheme do not collide. Tests ran in a detached screen session (fb33-r8; tmux is not installed on this Mac and was not installed). Workdir, DerivedData, log, and the throwaway simulator were removed after the run. No customer builder jobs, profiles, or keychains were touched. No sudo.

Times below are Atlantic/Madeira (WET, UTC+0). Start 18:10:47, end 18:18:52.

Commands (sha checked before and after):

. ~/tori-tests/env.sh
git clone --branch cursor/sync-upstream-e8336a2b-32 --single-branch https://github.com/Cap-go/capacitor-firebase.git ~/tori-tests/fb33-r8
cd ~/tori-tests/fb33-r8
git checkout 0afe7f563079988429956b9857c10bb55bc652e1
git rev-parse HEAD
# 0afe7f563079988429956b9857c10bb55bc652e1
bun i
xcrun simctl create tori-fb33-r8 com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro com.apple.CoreSimulator.SimRuntime.iOS-26-5
export IOS_TEST_UDID=<tori-fb33-r8>
# for each of analytics, authentication, firestore, functions, performance, storage:
export IOS_TEST_DERIVED_DATA=~/tori-tests/fb33-r8-dd-<pkg>
(cd packages/<pkg> && bun run verify:ios)
git rev-parse HEAD
# 0afe7f563079988429956b9857c10bb55bc652e1

Results (bun run verify:ios is pod install then scripts/ios-test.mjs; firestore uses --spm CapgoCapacitorFirebaseFirestore):

PackageXCTestsResultDuration
analytics4TEST SUCCEEDED87s (sim boot 46.0s, xcodebuild 39.1s)
authentication5, including testGetCurrentUserRejectsWhenFirebaseIsNotConfiguredTEST SUCCEEDED115s (xcodebuild 110.4s)
firestore (SwiftPM testTarget)4TEST SUCCEEDED137s (xcodebuild 107.9s)
functions3TEST SUCCEEDED50s (xcodebuild 46.9s)
performance3TEST SUCCEEDED58s (xcodebuild 52.5s)
storage3TEST SUCCEEDED34s (xcodebuild 32.7s)

All six suites passed on the first try at this sha. Isolated DerivedData avoided the earlier functions clash (GoogleUtilities_NSData when several Plugin-scheme packages shared one DerivedData path).