Repository navigation
Conversation
Every SwiftPM target and podspec that uses FirebaseCore's internal API (the FirebaseCore/Extension headers, or the internal symbols they declare) now depends on FirebaseCoreExtension explicitly. Today the Objective-C SDKs reach the Extension headers by path, through a header search path to the repository root, and link the internal symbols from FirebaseCore. Once FirebaseCore is reimplemented in Swift, FirebaseCoreExtension becomes an Objective-C target with its own implementation file: the FIRLog* functions and the kFIR* and FIRAuthStateDidChangeInternalNotification* constants move there. Targets that use them must depend on it, or they won't link. While FirebaseCore is still Objective-C, the new dependencies change nothing: FirebaseCoreExtension only has headers and an empty file. Package.swift: - SDK targets: FirebaseABTesting, FirebaseAppCheck, FirebaseAppDistribution, FirebaseCrashlytics, FirebaseDatabaseInternal, FirebaseInAppMessagingInternal, FirebaseInstallations, FirebaseMessaging, FirebasePerformance, FirebaseRemoteConfigInternal, and FirebaseFirestoreInternalWrapper (both the source and binary variants). - Wrappers of closed-source binaries: FirebaseAnalyticsWrapper, FirebaseAnalyticsCoreWrapper and FirebaseAnalyticsIdentitySupportTarget, because the FirebaseAnalytics binary uses kFIRLoggerAnalytics; and the binary FirebaseFirestoreInternalWrapper, because the FirebaseFirestoreInternal binary uses FIRLogBasic*, FIRSetLoggerLevel*, FIRIsLoggableLevel* and FIRAuthStateDidChangeInternalNotification*. - Test targets that import the Extension headers or module directly: CoreUnit, ABTestingUnit, AppDistributionUnit, AuthUnit, FirebaseCrashlyticsUnit, DatabaseUnit, FirebaseFunctionsObjCIntegration, MessagingUnit, PerformanceUnit, RemoteConfigUnit, FirebaseAppCheckUnit and FirebaseAILogicUnit. Podspecs: FirebaseABTesting, FirebaseAppCheck, FirebaseAppDistribution, FirebaseCrashlytics, FirebaseDatabase, FirebaseFirestoreInternal, FirebaseInAppMessaging, FirebaseInstallations, FirebaseMessaging, FirebasePerformance and FirebaseRemoteConfig, with the same version requirement as their FirebaseCore dependency. No source files or header search paths change. FirebaseAnalytics.podspec is left alone for now: it describes the closed-source binary, and adding the dependency would change the layout of the zip distribution. It's needed only once kFIRLoggerAnalytics moves to FirebaseCoreExtension, and will be coordinated with the release then.
Add FirebaseCore/Swift/Sources/FirebaseVersion.swift with `let firebaseVersion = "13.3.0"`, written like the declaration in Package.swift. It becomes the source of the version in code when FirebaseCore is implemented in Swift, replacing the Firebase_VERSION build setting. It is not compiled yet. The release tooling updates it with the same sed command as Package.swift (removing the temporary .bak files), and version-test checks that the two literals match.
…figuration to Swift
Using Gemini Code AssistThe 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
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 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. |
Generated by 🚫 Danger |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates key components of FirebaseCore from Objective-C to Swift, including configuration, logging, timestamps, bundle utilities, and the component container, while introducing a Clang module shim (FirebaseCoreSwiftShim) to maintain backward compatibility. The review feedback highlights several opportunities to improve type safety and idiomatic Swift usage. Specifically, it recommends replacing unsafe unsafeBitCast operations with safer Swift casting (as?) or selector checks in FirebaseComponentContainer, inheriting from NSObjectProtocol in private proxy protocols within SceneFinder to avoid manual method redeclarations, and properly deinitializing lockPointer before deallocation in UnfairLock.
- Emit Apache 2.0 copyright header in FirebaseCore-SwiftSnapshot.h via update_snapshot.sh and ignore leading comments up to #ifndef FIREBASECORE_SWIFT_H in check_snapshot.sh. - Match FIRLogger.h enum types in FirebaseLogger.swift @_cdecl functions (FIRGetLoggerLevel, FIRSetLoggerLevel, FIRIsLoggableLevel) to fix Xcode 26.2 MandatorySILLinker type mismatch. - Import FIRApp.h under !__has_feature(modules) in FirebaseCore-SwiftImport.h so standalone non-modular ObjC++ includes (e.g. FIRTimestamp.h in source Firestore) have FIRApp declared for the FIRCoreObjCAnchor category, and add ObjCPPStandaloneTimestampTests.mm. - Wire Firebase -> [FirebaseCore, FirebaseCoreSwiftShim], add Firebase to FirebaseCoreExtension, and expose FirebaseCore via FirebaseCoreTarget so Swift 'import Firebase' works for every product (including analytics-import-test) while keeping FirebaseCore portable to Linux; remove redundant downstream FirebaseCoreSwiftShim entries.
- Guard populateComponents(from:for:) with responds(to: #selector(_CoreLibraryClassProxy.componentsToRegister)) before unsafeBitCast. - Store component.creationBlock as AnyObject instead of unsafeBitCast. - Guard unsafeBitCast to ObjCComponentCreationBlock with an NSBlock isKind(of:) check (Swift's runtime as? cast returns nil for Objective-C NSBlocks), and add unit tests for non-conforming registrants and non-block entries. - Inherit NSObjectProtocol in _CoreSceneProxy instead of redeclaring isKindOfClass:. - Call lockPointer.deinitialize(count: 1) before deallocate() in UnfairLock.deinit.
…sions - Match Objective-C BOOL (`ObjCBool` on x86_64 macOS/Mac Catalyst, `Bool` elsewhere) in `FirebaseLogger.swift` `@_cdecl` signatures so Xcode 26.2 `MandatorySILLinker` succeeds on x86_64 macOS and Catalyst. - Nest internal `@objc(FIR...)` compatibility classes inside `_FirebaseCoreObjCImpl` and mark internal `@objc` mirror protocols `private` so `swiftc -application-extension` (`APPLICATION_EXTENSION_API_ONLY=YES`) does not emit duplicate `@interface`/`@protocol` declarations into `FirebaseCore-Swift.h` while preserving exported `_OBJC_CLASS_$_FIR...` symbols and protocol metadata in Release builds. - Dispatch `FIRLoggerCore` via a private protocol in `FirebaseCore/Extension/FIRLogger.m` instead of redeclaring `@interface FIRLoggerCore`.
Switches
FirebaseCoreto a Swift target, foldsFirebaseCoreInternalintoFirebaseCore, and ports all Phase 3 leaf types to Swift while preserving the public Swift/Objective-C APIs and the Objective-C runtime/binary-link ABI.This is a draft PR covering Phases 2 and 3 of the FirebaseCore Swift port, stacked on #17149 (
pb-core-swift-link-gate) with #17151 and #17152 cherry-picked underneath until those Phase 1 PRs merge tomain.Changes
Phase 2 — Swift target &
FirebaseCoreInternalconsolidationFirebaseCoreinPackage.swiftto a Swift target (FirebaseCore/Swift/Sources), re-exporting remaining Objective-C public classes fromFirebaseCoreObjCviaFirebaseCoreExports.swiftand the transitionalFIRCoreObjCAnchorprotocol.FirebaseCoreInternalintoFirebaseCore, exposingUnfairLockvia@_spi(FirebaseCoreInternal)(with anNSLockfallback for non-Apple platforms), moving heartbeat unit tests toFirebaseCore/Tests/HeartbeatUnit, and portingFIRHeartbeatLoggerandFIRHeaderValueFromHeartbeatsPayloadto Swift (HeartbeatLogger.swift).FirebaseCoreSwiftShimso Swift targets importing Clang modules that do@import FirebaseCore;(such asFirebaseCoreExtension) resolve native Swift types cleanly, and added directFirebaseCoredependencies on Objective-C test targets that importFirebaseCoreExtensionheaders.FirebaseCoreInternalconsumers (FirebaseAI,FirebaseAuth,FirebaseFunctions,FirebaseSessions,FirebaseAppDistributionInternal,FirebaseInstallationstests, andCoreUnit).Phase 3 — Leaf-type Swift ports
Timestampand header snapshot infrastructure: PortedTimestamp(FIRTimestamp) andraiseCoreExceptionto Swift (Timestamp.swift,CoreExceptions.swift), convertedFIRTimestamp.hto a forwarding header, addedFirebaseCore-SwiftImport.hand checked-inFirebaseCore-SwiftSnapshot.h(for non-modular ObjC++ under Swift Build and transitive ObjC dependents ofFirebaseCoreSwiftShim), and addedscripts/core_api/{gen_header,update_snapshot,check_snapshot}.sh.SceneFinder: PortedFIRSceneFinder(SceneFinder.swift) for iOS/tvOS/visionOS using private non-FIRObjective-C proxy protocols so UIKit objects, test fakes, and OCMock proxies behave identically.FIRFirebaseUserAgent(FirebaseUserAgent.swift),FIRBundleUtil(BundleUtil.swift), andFIRAnalyticsConfiguration(AnalyticsConfiguration.swift), preserving#if DEBUGtest seams.FirebaseConfiguration: PortedFirebaseLoggerLevel(@nonexhaustive @objc(FIRLoggerLevel)),FirebaseLogger(@_spi(FirebaseCoreInternal)plus@_cdeclC entry points andFIRLoggerCore), andFirebaseConfiguration(FIRConfiguration). MovedkFIRLogger*constants and variadicFIRLog*/FIRLogBasic*shims intoFirebaseCore/Extension/FIRLogger.m(checkingFIRIsLoggableLevelbefore formatting) and migrated in-repo SwiftFirebaseLogger.logcall sites to@_spi(FirebaseCoreInternal).FIRComponent,FIRComponentType, andFIRComponentContainer(Component.swift,ComponentContainer.swift) with a portableObjectIdentifier-keyed Swift component registry alongside the AppleProtocol-keyed Objective-C bridge (NSRecursiveLockfor reentrant dependency resolution andappWillBeDeleted:callbacks, plus ObjC proxy protocols forOCMockand fake apps such asFIRFakeApp).UnfairLockThreadSanitizer fix: StoredUnfairLock's value out-of-line viaUnsafeMutablePointer<Value>and madelockPointerimmutable (let) so zero-sizedValuetypes (Void) do not alias offset 0 (isa) ofselfand trigger a Swift access race under TSan.scripts/core_api/core_api.pyto buildFirebaseCore.swiftmoduleandFirebaseCore-Swift.hacross all 5 Apple platforms, skip@_spinodes insurface_decls(), and normalize Swift-generated Objective-C USRs/default attributes; added reviewed Phase 3 entries toFirebaseCore/Tests/APIBaselines/allowlist.json; updatedscripts/core_api/check_binary_link.pyfor Swift__PROTOCOL_*symbols andFirebaseCore/Swift/Sources; updatedscripts/core_api/coverage.pyandLogCodeTests.swiftforFirebaseCore/Swift/Sources; addedSwiftComponentRegistryTests.swiftandFIRLogBasic*tests inLoggerTests.swift.Not changed / known limitations
FIRVersion,FIROptions, andFIRAppremain in Objective-C (FirebaseCoreObjC) and will be ported in Phase 4, along with planned deprecations and removal ofFirebaseCoreObjCandFIRCoreObjCAnchor.FirebaseCore.podspec,FirebaseCoreInternal.podspec), CI workflow updates, and theFirebaseCore/CHANGELOG.mdentry are deferred to Phases 4–5 (so CocoaPods lint jobs are not expected to pass on this draft PR yet).API Changes
No breaking public Swift or Objective-C API changes. Reviewed differences allowlisted in
FirebaseCore/Tests/APIBaselines/allowlist.json:-[FIRTimestamp init]is now callable from Objective-C (returning the current time);+[FIRTimestamp timestamp]remains unchanged.FirebaseLoggerLevelcarries@nonexhaustiveon Swift 6.2+ to preserveNS_ENUMswitch exhaustiveness (@unknown default), andFIRLoggerLevelMin/FIRLoggerLevelMaxare provided as Objective-C compatibility macros inFirebaseCoreObjC.h.NSObject/NSCopyingoverrides onTimestampand inherited-[FIRConfiguration init]in the generated header, plus the transitionalFIRCoreObjCAnchor(_FirebaseCoreObjCAnchor) protocol removed in Phase 4.Testing
scripts/core_api/core_api.py): Two-stepdump --out+check --currentwith Xcode 26.5 (Swift 6.3.2) passed acrossios,catalyst,macos,tvos,watchos, and Objective-C (clang -extract-api).scripts/core_api/check_snapshot.sh): Passed on Xcode 26.2 (full), Xcode 26.5 (--decls-only), and Xcode 27.2 (--decls-only) for bothmacosxandiphoneos.scripts/core_api/run_tsan.sh): Passed allCoreSwiftUnittests on macOS (Xcode 27.2) with zero TSan reports. (Prior to theUnfairLockfix,ConcurrencyTests.testConcurrentConfigureFindAndDelete,testConcurrentDataCollectionFlag, andtestConcurrentDuplicateConfigurefailed with a Swift access race inUnfairLock.withLock.)scripts/core_api/coverage.py check): Passed on macOS (Xcode 27.2) at 88.67% total line coverage (baseline 88.53%).iPhone 17OS 27.2):CoreSwiftUnit,CoreUnit,CoreRuntimeABI(Debug & Release, verified zero test symbols in Releasenm -a),CoreSwiftAPI,CoreObjCAPI, andFirebaseCoreInternalTestspassed with zero warnings inFirebaseCore.CoreAnalyticsLink,CoreFirestoreLink, dynamicCoreBinaryLink-Package, andscripts/core_api/check_binary_link.py checkpassed.DatabaseUnit,DatabaseUnitSwift,AuthUnit,FirebaseFunctionsUnit,FirebaseSessionsUnit,FirebaseStorageUnit,FirebaseFirestoreTests,FirebaseAppCheckUnit,ABTestingUnit,FirebaseCrashlyticsUnit,MessagingUnit,AnalyticsObjCAPI,AnalyticsSwiftUnit,objc-import-test,swift-test, andversion-testpassed;clang -arch x86_64 -Wall -Wextra -Werror -fsyntax-onlypassed onFirebaseCore/Extension/FIRLogger.m.scripts/style.sh test-only(all changed Swift/ObjC files),scripts/check_whitespace.sh,scripts/check_imports.swift,python3 -m py_compile, andbash -nall passed.FIREBASE_SOURCE_FIRESTORE), and Linux builds.#no-changelog
This PR was prepared with AI assistance.