Skip to content

[🐛] 🔥 Timestamp/FieldValue issues / plus Firestore crashes in iOS Release Mode Only #8401

Open
@cjfritz

Description

@cjfritz

Issue

I have recently upgraded my project from v18.9.0 to 21.12.0 (also affects 21.10.0), and it appears that for iOS release variants only, the following crash is occurring when attempting to utilize the Timestamp object from the default export from @react-native-firebase/firestore. Here is the relevant code:

import firestore from '@react-native-firebase/firestore';

export const createFirestoreTimestamp = () => firestore.Timestamp.now();

When the createFirestoreTimestamp function is called, the following crash is reported:

u.default.Timestamp.now is not a function. (In 'u.default.Timestamp.now()', 'u.default.Timestamp.now' is undefined)

I've noticed that when the code is updated to use the named Timestamp class import and make use of its static now method, no crash occurs:

import firestore, { FirebaseFirestoreTypes, Timestamp } from '@react-native-firebase/firestore';

export const createFirestoreTimestamp = () => Timestamp.now(); // this does not crash!

Additionally, I've seen that a usage of FieldArray in my project is also producing a similar crash:

import firestore from '@react-native-firebase/firestore';

dispatch(updateDriverMetadata({ favoriteContacts: firestore.FieldValue.arrayUnion(item.id) }));

Specifically when firestore.FieldValue.arrayUnion is called, the following crash occurs:

n.default.FieldValue.arrayUnion is not a function. (In 'n.default.FieldValue.arrayUnion(l.id)', 'n.default.FieldValue.arrayUnion' is undefined)

I've seen that with v22 coming up, the modular API approach as explained here is favored over default exports, however I did not see any requirements that this needed to occur with v21 or any versions prior in the changelog, even though it appears that the modular functionality is being slowly exposed. Has there possibly been a regression introduced with the modular API compatibility changes? Both Android and iOS debug variants work perfectly fine with the existing code we have implemented, and Android release variants also appear not to be affected.

I saw this current issue open that may be relevant as well: #8369


Project Files

Javascript

Click To Expand

package.json:

  "dependencies": {
    "@react-native-firebase/analytics": "21.12.0",
    "@react-native-firebase/app": "21.12.0",
    "@react-native-firebase/auth": "21.12.0",
    "@react-native-firebase/firestore": "21.12.0",
    "@react-native-firebase/messaging": "21.12.0",
    "@react-native-firebase/remote-config": "21.12.0",
    ...
  }

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# Relevant details of Podfile for react-native-firebase setup:
use_frameworks! :linkage => :static
...
target 'MyApp' do
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseFirestore', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseFirestoreInternal', :modular_headers => true
  pod 'FirebaseRemoteConfig', :modular_headers => true
  pod 'FirebaseABTesting', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true

ios/AppDelegate.mm:

#import <Firebase.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  ...
}


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 66.78 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.10.0
    path: ~/.nvm/versions/node/v22.10.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.0
    path: ~/.nvm/versions/node/v22.10.0/bin/npm
  Watchman:
    version: 2023.06.12.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/user/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.2 AI-222.4459.24.2221.10121639
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 21.0.3
    path: /Users/user/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 3.3.6
    path: /Users/user/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 14.1.0
    wanted: ^14.1.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: ^0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false
  • Platform that you're experiencing the issue on:
    • [x ] iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 21.12.0, 21.10.0
  • Firebase module(s) you're using that has the issue:
    • @react-native-firebase/firestore
  • Are you using TypeScript?
    • Y & 5.3.3


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions