invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.22k forks source link

[🐛⚠️] iOS Build Fails - Value of optional type '?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider' (Optional Chaining) #7666

Closed VictorioMolina closed 8 months ago

VictorioMolina commented 8 months ago

Scenario

Last week I was able to compile my project (Expo EAS Build) without errors.

Today, without modifying anything (didn't upgrade any dependency), I have started getting this error on my iOS AdHoc compilation:

Run Fastlane Errors

Copying   @react-native-firebase/storage ../../../Users/expo/Library/Developer/Xcode/DerivedData/Advice-dzlzwedukqkcvxgkbpzvxdpjkyli/Build/Intermediates.noindex/ArchiveIntermediates/Advice/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/FirebaseStorage.framework/Headers/FirebaseStorage-umbrella.h ➜ ios/Pods/Target/ Support/ Files/FirebaseStorage/FirebaseStorage-umbrella.h

› Copying   @react-native-firebase/storage ../../../Users/expo/Library/Developer/Xcode/DerivedData/Advice-dzlzwedukqkcvxgkbpzvxdpjkyli/Build/Intermediates.noindex/ArchiveIntermediates/Advice/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/FirebaseStorage.framework/Headers/FIRStorageTypedefs.h ➜ ios/Pods/FirebaseStorage/FirebaseStorage/Typedefs/FIRStorageTypedefs.h

❌  (/Users/expo/workingdir/build/packages/app/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:73:12)

  71 |     let provider = ComponentType<StorageProvider>.instance(for: StorageProvider.self,
  72 |                                                            in: app.container)
> 73 |     return provider.storage(for: Storage.bucket(for: app))
     |            ^ value of optional type '?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider'
  74 |   }
  75 | 
  76 |   /**

❌  (/Users/expo/workingdir/build/packages/app/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:88:12)

  86 |     let provider = ComponentType<StorageProvider>.instance(for: StorageProvider.self,
  87 |                                                            in: app.container)
> 88 |     return provider.storage(for: Storage.bucket(for: app, urlString: url))
     |            ^ value of optional type '?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider'
  89 |   }
  90 | 
  91 |   /**

❌  (/Users/expo/workingdir/build/packages/app/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:291:39)

  289 |   init(app: FirebaseApp, bucket: String) {
  290 |     self.app = app
> 291 |     auth = ComponentType<AuthInterop>.instance(for: AuthInterop.self,
      |                                       ^ cannot assign value of type '?' to type 'any AuthInterop'
  292 |                                                in: app.container)
  293 |     appCheck = ComponentType<AppCheckInterop>.instance(for: AppCheckInterop.self,
  294 |                                                        in: app.container)

❌  (/Users/expo/workingdir/build/packages/app/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:293:47)

  291 |     auth = ComponentType<AuthInterop>.instance(for: AuthInterop.self,
  292 |                                                in: app.container)
> 293 |     appCheck = ComponentType<AppCheckInterop>.instance(for: AppCheckInterop.self,
      |                                               ^ cannot assign value of type '?' to type 'any AppCheckInterop'
  294 |                                                        in: app.container)
  295 |     storageBucket = bucket
  296 |     host = "firebasestorage.googleapis.com"

Package Versions

Since I was using the following dependencies

    "@react-native-firebase/analytics": "^18.7.3",
    "@react-native-firebase/app": "^18.7.3",
    "@react-native-firebase/auth": "^18.7.3",
    "@react-native-firebase/firestore": "^18.7.3",
    "@react-native-firebase/functions": "^18.7.3",
    "@react-native-firebase/storage": "^18.7.3",

I decided to upgrade to the latest one @^19.0.0.

    "@react-native-firebase/analytics": "^19.0.0",
    "@react-native-firebase/app": "^19.0.0",
    "@react-native-firebase/auth": "^19.0.0",
    "@react-native-firebase/firestore": "^19.0.0",
    "@react-native-firebase/functions": "^19.0.0",
    "@react-native-firebase/storage": "^19.0.0",

I have also tried upgrading EAS with Expo 48, 49 and the latest release and images, with CocoaPods v1.15.2, and the error still persists.

Is anyone experiencing the same issue?

geoffcfchen commented 8 months ago

Yes. I just got exactly the same error today, while everything worked fine last week. I am using Expo 49 SDK. The following is a part of my package.json.

"dependencies": { "@react-native-firebase/app": "^18.4.0", "@react-native-firebase/auth": "^18.4.0", "@react-native-firebase/firestore": "^18.4.0", "@react-native-firebase/storage": "^18.4.0", "expo": "~49.0.10", "react": "18.2.0", "react-native": "^0.72.6", }, "devDependencies": { "@babel/core": "^7.20.0" }, "private": true }

Given the error, "value of optional type '?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider", which indicates that the Swift compiler expects an optional value to be unwrapped before its properties or methods can be accessed, I think that it is more about the Firebase Storage SDK's internal handling of values than our project's code directly. I hope someone can help. Thanks

VictorioMolina commented 8 months ago

Yep, it’s a minimal issue with nils handling. Hope it’s fixed soon 🥺 I downgraded the package too but nothing. Did you try @17.5.0? @geoffcfchen

Starting to think the issue itself is in the latest Google Firebase iOS SDK package and not directly in this wrapper for React Native (?).

VictorioMolina commented 8 months ago

Yep, i assume its an already fixed issue in Firebase iOS sdk https://github.com/firebase/firebase-ios-sdk/pull/12391

guard let provider = ComponentType<StorageProvider>.instance(for: StorageProvider.self,
                                                                 in: app.container) else {
      fatalError("No \(StorageProvider.self) instance found for Firebase app: \(app.name)")
    }
    return provider.storage(for: Storage.bucket(for: app, urlString: url))

@mikehardy @Salakar

geoffcfchen commented 8 months ago

@VictorioMolina could you share how you solve this issue? Just reinstall react-native-firebase/storage? I am using expo EAS build right now and would appreciate it if you could share some advice. Thanks!

geoffcfchen commented 8 months ago

17.5.0

No I did not try 17.5.0...

geoffcfchen commented 8 months ago

Thanks for sharing the information. It seems to me that this problem is still not resolved. It was fine last week but now it can't work, so I think that there are some changes under the hood. I hope some one can point us in a direction...

Btw, how do you know it is related to https://github.com/firebase/firebase-ios-sdk/pull/12391?

VictorioMolina commented 8 months ago

@geoffcfchen take a look at the changes introduced on FirebaseStorage/Sources/Storage.swift in this commit:

https://github.com/firebase/firebase-ios-sdk/commit/1ed6d66b2010539bf21abf66b942dcf89384bd75

That’s why I feel we need to update the firebase iOS sdk to a greater version than v10.21.0

geoffcfchen commented 8 months ago

I see.

Since I am working on the expo project, I only have the following packages in my package.json

"@react-native-firebase/app": "18.9.0",
"@react-native-firebase/auth": "18.9.0",
"@react-native-firebase/firestore": "18.9.0",
"@react-native-firebase/storage": "18.9.0",

and the following plugins in app.json.

 "plugins": [
  "expo-apple-authentication",
  "@react-native-firebase/app",
  "@react-native-firebase/auth",
  [
    "expo-build-properties",
    {
      "ios": {
        "useFrameworks": "static"
      }
    }
  ],

But I think that we encountered the same issue. I don't think that we are the only one. Those who used the EAS build recently should also encounter the same issue...

VictorioMolina commented 8 months ago

@geoffcfchen It’s correct, it seems impossible to build with expo in the current state. Ignore the custom config plug-in I was implementing, it’s not working and looks like a hack which could lead to extra problems… definitively, not a good solution, I am deleting it.

We will need to wait for the package maintainers.

geoffcfchen commented 8 months ago

Someone mentioned a solution

https://stackoverflow.com/questions/78027770/upgrading-to-expo-50-can%C2%B4t-build-ios

But it requires ejecting from Expo...

VictorioMolina commented 8 months ago

@geoffcfchen It's not the same issue but I also faced it today.

"plugins": [
      "@react-native-firebase/app",
      "./src/plugins/maps/withReactNativeMaps",
      "./src/plugins/splash/withAndroidSplashScreen",
      [
        "expo-build-properties",
        {
          "android": {
            "compileSdkVersion": 34,
            "targetSdkVersion": 34,
            "buildToolsVersion": "34.0.0",
            "extraProguardRules": "-keep class com.google.android.gms.internal.consent_sdk.** { *; }"
          },
          "ios": {
            "deploymentTarget": "13.4", <-------- Just upgrade the minimum deployment target for iOS
            "useFrameworks": "static"
          }
        }
      ],
      [
        "expo-notifications",
        {
          "icon": "./assets/images/logo/notification/notification-icon.png",
          "color": "#ffffff"
        }
      ]
    ],

There is no need to eject to the bare workflow, you can stay managed or semi-managed with EAS.

geoffcfchen commented 8 months ago

Maybe a related post

https://github.com/firebase/flutterfire/issues/12429

aslihanturkdonmez commented 8 months ago

I don't using expo, i use cli and the error occurs there too

VictorioMolina commented 8 months ago

@geoffcfchen yep, it’s the same issue. Also, it seems the solution is just to upgrade the firebase iOS sdk version, but, as I mentioned before, I feel it’s not the best approach to touch the Podfile with an expo plugin. It’s better to wait for the maintainers of react-native-firebase.

AleshkovDenis commented 8 months ago

any updates?

vladi-klmv commented 8 months ago

any updates?

VictorioMolina commented 8 months ago

@AleshkovDenis @vladi-klmv I submitted a pull request to fix the issue. Pls, check it out and if you think something is missing, update it :) or create a patch package. This issue is strongly retaining us.

AleshkovDenis commented 8 months ago

@VictorioMolina Did you try build your app with patched package changes?

VictorioMolina commented 8 months ago

@AleshkovDenis Nop, I didn't, just prefer to wait for any updates on this repo. But if you do, let us know if the sdk version upgrade fixes the issue.

cwackerfuss commented 8 months ago

@VictorioMolina and @AleshkovDenis - the sdk version upgrade does fix the issue when you patch the package.

If anyone would like to use this solution while we wait on the official update, it's very straightforward with a tool like patch-package, or if you use yarn v2+ or pnpm, those have built-in support for package patching.

Here's how I did it on Yarn v2+ (I use 4.0.2):

AleshkovDenis commented 8 months ago

@cwackerfuss Can you write the path to the file that needs to be changed? Or show a successful diff?

VictorioMolina commented 8 months ago

@AleshkovDenis check the changed files in the pull request. https://github.com/invertase/react-native-firebase/pull/7668

geoffcfchen commented 8 months ago

@cwackerfuss Can you write the path to the file that needs to be changed? Or show a successful diff?

node_modules/@react-native-firebase/app/package.json

ishikaj12 commented 8 months ago

Hi, I'm running into the same Fastlane issues with Firebase Storage. I tried to do the patch-package command (yarn patch-package @react-native-firebase/app) but got this message:

patch-package 8.0.0 • Creating temporary folder • Installing @react-native-firebase/app@18.7.3 with yarn • Diffing your files with clean files ⁉️ Not creating patch file for package '@react-native-firebase/app' ⁉️ There don't appear to be any changes. error Command failed with exit code 1.

Does anyone know what to do in this case? Thank you!

geoffcfchen commented 8 months ago

Hi, I'm running into the same Fastlane issues with Firebase Storage. I tried to do the patch-package command (yarn patch-package @react-native-firebase/app) but got this message:

patch-package 8.0.0 • Creating temporary folder • Installing @react-native-firebase/app@18.7.3 with yarn • Diffing your files with clean files ⁉️ Not creating patch file for package '@react-native-firebase/app' ⁉️ There don't appear to be any changes. error Command failed with exit code 1.

Does anyone know what to do in this case? Thank you!

yarn patch-package @react-native-firebase/app --exclude

geoffcfchen commented 8 months ago

For those who are working on an Expo project (Expo's managed workflow) and need to fix the EAS building error right now before the official updates, you can do

  1. Install patch-package and postinstall-postinstall if you haven't already npm install patch-package postinstall-postinstall --save-dev

  2. Edit the node_modules/@react-native-firebase/app/package.json to change the Firebase version to 10.22.0. "sdkVersions": { "ios": { "firebase": "10.22.0",

  3. Include --exclude when creating a patch file in a patches/ directory since you only edited package.json which will be ignored by default npx patch-package @react-native-firebase/app --exclude

  4. Modify your package.json to include the postinstall script "scripts": { "postinstall": "patch-package" }

  5. Rebuild your project Ex: eas build --profile development --platform ios

GibbyBox commented 8 months ago

A workaround I'm using is to pin the related pods via a config plugin. It does require knowing what pods to pin and at what versions. I figured out which pods and versions to use by pasting the output of the pod install steps for a working build and a failing build in a text differ.


[ "expo-build-properties", { 
    "ios": {
        "useFrameworks": "static",
        "extraPods": [
            { "name": "FirebaseAppCheckInterop", "version": "= 10.21.0" },
            { "name": "FirebaseAuthInterop", "version": "= 10.21.0" },
            { "name": "FirebaseCoreExtension", "version": "= 10.21.0" },
            { "name": "FirebaseCoreInternal", "version": "= 10.21.0" },
            { "name": "FirebaseFirestoreInternal", "version": "= 10.21.0" },
            { "name": "FirebaseInstallations", "version": "= 10.21.0" },
            { "name": "FirebaseMessagingInterop", "version": "= 10.21.0" },
            { "name": "FirebaseSharedSwift", "version": "= 10.21.0" },
            { "name": "GoogleUtilities", "version": "= 7.12.0" },
            { "name": "PromisesObjC", "version": "= 2.3.1" },
            { "name": "leveldb-library", "version": "= 1.22.3" }
        ]
    }
}]
VictorioMolina commented 8 months ago

@GibbyBox shouldn’t it be 10.22.0/10.23.0?

GibbyBox commented 8 months ago

With what I encountered it was 10.22.0 giving me these issues. I can certainly upgrade to 10.23.0, but decided to roll back. I was unaware of this discussion until recently. I even built a repro for this.

https://github.com/GibbyBox/repro-firebase-pods-issue-3-5-2024

VictorioMolina commented 8 months ago

@GibbyBox The issue got solved here, in v10.22.0 https://github.com/firebase/firebase-ios-sdk/commit/1ed6d66b2010539bf21abf66b942dcf89384bd75

Currently, react-native-firebase wraps firebase-ios-sdk v10.21.0 https://github.com/invertase/react-native-firebase/blob/main/packages/app/package.json

Could you please re-check? Is it compiling correctly with the extra pods solution? No crashes while testing the app?

GibbyBox commented 8 months ago

@VictorioMolina I'm positive. The pods I rolled back to are what's being used in my production app currently.

GibbyBox commented 8 months ago

So I double checked the install pods log for the attempt that failed. There is a mix of using v10.21.0 and v10.22.0 for the firebase related pods.

Installing Firebase (10.21.0) Installing FirebaseAppCheck (10.21.0) Installing FirebaseAppCheckInterop (10.22.0) Installing FirebaseAuth (10.21.0) Installing FirebaseAuthInterop (10.22.0) Installing FirebaseCore (10.21.0) Installing FirebaseCoreExtension (10.22.0) Installing FirebaseCoreInternal (10.22.0) Installing FirebaseDatabase (10.21.0) Installing FirebaseFirestore (10.21.0) Installing FirebaseFirestoreInternal (10.22.0) Installing FirebaseFunctions (10.21.0) Installing FirebaseMessagingInterop (10.22.0) Installing FirebaseSharedSwift (10.22.0) Installing FirebaseStorage (10.21.0)

Show the entire log

``` Using Expo modules [Expo] Enabling modular headers for pod ExpoModulesCore [Expo] Enabling modular headers for pod React-Core [Expo] Enabling modular headers for pod React-RCTAppDelegate [Expo] Enabling modular headers for pod expo-dev-menu-interface [Expo] Enabling modular headers for pod EXManifests [Expo] Enabling modular headers for pod EXUpdatesInterface [Expo] Enabling modular headers for pod expo-dev-menu [Expo] Enabling modular headers for pod RCT-Folly [Expo] Enabling modular headers for pod glog [Expo] Enabling modular headers for pod expo-dev-launcher Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration Auto-linking React Native modules for target `reprofirebasepodsissue352024`: RNFBApp, RNFBAppCheck, RNFBAuth, RNFBDatabase, RNFBFirestore, RNFBFunctions, and RNFBStorage Framework build type is static framework [Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json [Codegen] generating an empty RCTThirdPartyFabricComponentsProvider Analyzing dependencies Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec` [Codegen] Found FBReactNativeSpec Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec` [Codegen] Found rncore Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec` Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec` Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec` [Hermes] Using release tarball from URL: https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.73.4/react-native-artifacts-0.73.4-hermes-ios-debug.tar.gz % Total % Received % Xferd Average Speed Time Time Time Curren t Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 16.2M 100 16.2M 0 0 49.7M 0 --:--:-- --:-- :-- --:--:-- 50.3M % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 12.3M 100 12.3M 0 0 77.7M 0 --:--:-- --:--:- - --:--:-- 79.5M Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/` CocoaPods 1.15.0 is available. To update use: `gem install cocoapods` For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.15.0 Downloading dependencies Installing AppCheckCore (10.18.1) Installing BoringSSL-GRPC (0.0.24) Installing DoubleConversion (1.1.6) Installing EXConstants (15.4.5) Installing EXFont (11.10.3) Installing EXJSONUtils (0.12.3) Installing EXManifests (0.13.2) Installing EXUpdatesInterface (0.15.3) Installing Expo (50.0.8) Installing ExpoFileSystem (16.0.7) Installing ExpoKeepAwake (12.8.2) Installing ExpoModulesCore (1.11.9) Installing FBLazyVector (0.73.4) Installing FBReactNativeSpec (0.73.4) Installing Firebase (10.21.0) Installing FirebaseAppCheck (10.21.0) Installing FirebaseAppCheckInterop (10.22.0) Installing FirebaseAuth (10.21.0) Installing FirebaseAuthInterop (10.22.0) Installing FirebaseCore (10.21.0) Installing FirebaseCoreExtension (10.22.0) Installing FirebaseCoreInternal (10.22.0) Installing FirebaseDatabase (10.21.0) Installing FirebaseFirestore (10.21.0) Installing FirebaseFirestoreInternal (10.22.0) Installing FirebaseFunctions (10.21.0) Installing FirebaseMessagingInterop (10.22.0) Installing FirebaseSharedSwift (10.22.0) Installing FirebaseStorage (10.21.0) Installing GTMSessionFetcher (3.3.1) Installing GoogleUtilities (7.13.0) Installing PromisesObjC (2.4.0) Installing RCT-Folly (2022.05.16.00) Installing RCTRequired (0.73.4) Installing RCTTypeSafety (0.73.4) Installing RNFBApp (19.0.0) Installing RNFBAppCheck (19.0.0) Installing RNFBAuth (19.0.0) Installing RNFBDatabase (19.0.0) Installing RNFBFirestore (19.0.0) Installing RNFBFunctions (19.0.0) Installing RNFBStorage (19.0.0) Installing React (0.73.4) Installing React-Codegen (0.73.4) Installing React-Core (0.73.4) Installing React-CoreModules (0.73.4) Installing React-Fabric (0.73.4) Installing React-FabricImage (0.73.4) Installing React-ImageManager (0.73.4) Installing React-Mapbuffer (0.73.4) Installing React-NativeModulesApple (0.73.4) Installing React-RCTActionSheet (0.73.4) Installing React-RCTAnimation (0.73.4) Installing React-RCTAppDelegate (0.73.4) Installing React-RCTBlob (0.73.4) Installing React-RCTFabric (0.73.4) Installing React-RCTImage (0.73.4) Installing React-RCTLinking (0.73.4) Installing React-RCTNetwork (0.73.4) Installing React-RCTSettings (0.73.4) Installing React-RCTText (0.73.4) Installing React-RCTVibration (0.73.4) Installing React-callinvoker (0.73.4) Installing React-cxxreact (0.73.4) Installing React-debug (0.73.4) Installing React-graphics (0.73.4) Installing React-hermes (0.73.4) Installing React-jserrorhandler (0.73.4) Installing React-jsi (0.73.4) Installing React-jsiexecutor (0.73.4) Installing React-jsinspector (0.73.4) Installing React-logger (0.73.4) Installing React-nativeconfig (0.73.4) Installing React-perflogger (0.73.4) Installing React-rendererdebug (0.73.4) Installing React-rncore (0.73.4) Installing React-runtimeexecutor (0.73.4) Installing React-runtimescheduler (0.73.4) Installing React-utils (0.73.4) Installing ReactCommon (0.73.4) Installing RecaptchaInterop (100.0.0) Installing SocketRocket (0.6.1) Installing Yoga (1.14.0) Installing abseil (1.20220623.0) Installing boost (1.83.0) Installing expo-dev-client (3.3.9) Installing expo-dev-launcher (3.6.7) Installing expo-dev-menu (4.5.6) Installing expo-dev-menu-interface (1.7.2) Installing fmt (6.2.1) Installing gRPC-C++ (1.49.1) Installing gRPC-Core (1.49.1) Installing glog (0.3.5) Installing hermes-engine (0.73.4) Installing leveldb-library (1.22.4) Installing libevent (2.1.12) Installing nanopb (2.30909.1) Generating Pods project Setting USE_HERMES build settings Setting REACT_NATIVE build settings Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /Users/expo/workingdir/build/ios/reprofirebasepodsissue352024.xcodeproj Pod install took 256 [s] to run Integrating client project [!] Please close any current Xcode sessions and use `reprofirebasepodsissue352024.xcworkspace` for this project from now on. [Expo] Installing the build script for target reprofirebasepodsissue352024 expo_patch_react_imports! took 0.0842 seconds to transform files. Pod installation complete! There are 71 dependencies from the Podfile and 97 total pods installed. [!] `` attempted to initialize an object with an unknown UUID. `ACEE3F02404B4330AE5C195E` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded. [!] Can't merge pod_target_xcconfig for pod targets: ["expo-dev-menu", "Main", "ReactNativeCompatibles", "SafeAreaView", "Vendored"]. Singular build setting DEFINES_MODULE has different values. [!] Can't merge pod_target_xcconfig for pod targets: ["expo-dev-menu", "Main", "ReactNativeCompatibles", "SafeAreaView", "Vendored"]. Singular build setting DEFINES_MODULE has different values. [!] hermes-engine has added 1 script phase. Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information. ```

GibbyBox commented 8 months ago

In that flutterfire issue you linked, there is this https://github.com/firebase/flutterfire/issues/12429#issuecomment-1978209797

After investigation, it seems that some internal libraries in the native iOS SDK are not strongly linked to a version. When the iOS team released 10.22.0 yesterday some dependencies got upgraded without the main package.

@VictorioMolina Can you double check what version of the pods are installed in your failing builds, specifically if there is a mismatch in FirebaseCoreExtension, FirebaseCore, and FirebaseStorage?

What's likely happening on EAS for us is that FirebaseCoreExtension is on the 10.22.0. The interface defined in it indicate that the provider is nullable, but then the implementations in FirebaseCore and FirebaseStorage are on the 10.21.0 where it's missing the change to handle it being nullable.

Having all of them on the same version is the solution. Your PR should do that.

VictorioMolina commented 8 months ago

@GibbyBox Thank you for your workaround!! Could you please share the final state of the extra pods? AFAIK, the problem with nils is in the storage package.

womj commented 8 months ago
target 'sociablesui' do
  config = use_native_modules!

  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true
  pod 'RNFBStorage', :path => '../node_modules/@react-native-firebase/storage'
  $FirebaseSDKVersion = '10.22.0'

In your podfile works

Specify the new version of firebase sdk 10.22.0

laxyloginext commented 8 months ago

Thanks @womj its works.

GibbyBox commented 8 months ago

@GibbyBox Thank you for your workaround!! Could you please share the final state of the extra pods? AFAIK, the problem with nils is in the storage package.

Installing Firebase (10.21.0)
Installing FirebaseAppCheck (10.21.0)
Installing FirebaseAppCheckInterop (10.21.0)
Installing FirebaseAuth (10.21.0)
Installing FirebaseAuthInterop (10.21.0)
Installing FirebaseCore (10.21.0)
Installing FirebaseCoreExtension (10.21.0)
Installing FirebaseCoreInternal (10.21.0)
Installing FirebaseDatabase (10.21.0)
Installing FirebaseFirestore (10.21.0)
Installing FirebaseFirestoreInternal (10.21.0)
Installing FirebaseFunctions (10.21.0)
Installing FirebaseInstallations (10.21.0)
Installing FirebaseMessagingInterop (10.21.0)
Installing FirebaseSharedSwift (10.21.0)
Installing FirebaseStorage (10.21.0)
Show the entire log

``` Using Expo modules [Expo] Enabling modular headers for pod ExpoModulesCore [Expo] Enabling modular headers for pod React-Core [Expo] Enabling modular headers for pod React-RCTAppDelegate [Expo] Enabling modular headers for pod expo-dev-menu-interface [Expo] Enabling modular headers for pod EXManifests [Expo] Enabling modular headers for pod EXUpdatesInterface [Expo] Enabling modular headers for pod expo-dev-menu [Expo] Enabling modular headers for pod RCT-Folly [Expo] Enabling modular headers for pod glog [Expo] Enabling modular headers for pod expo-dev-launcher Adding extra pod - FirebaseAppCheckInterop (= 10.21.0) Adding extra pod - FirebaseAuthInterop (= 10.21.0) Adding extra pod - FirebaseCoreExtension (= 10.21.0) Adding extra pod - FirebaseCoreInternal (= 10.21.0) Adding extra pod - FirebaseFirestoreInternal (= 10.21.0) Adding extra pod - FirebaseInstallations (= 10.21.0) Adding extra pod - FirebaseMessagingInterop (= 10.21.0) Adding extra pod - FirebaseSharedSwift (= 10.21.0) Adding extra pod - GoogleUtilities (= 7.12.0) Adding extra pod - PromisesObjC (= 2.3.1) Adding extra pod - leveldb-library (= 1.22.3) Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration Auto-linking React Native modules for target `reprofirebasepodsissue352024`: RNFBApp, RNFBAppCheck, RNFBAuth, RNFBDatabase, RNFBFirestore, RNFBFunctions, and RNFBStorage Framework build type is static framework [Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json [Codegen] generating an empty RCTThirdPartyFabricComponentsProvider Analyzing dependencies Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec` [Codegen] Found FBReactNativeSpec Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec` [Codegen] Found rncore Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec` Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec` Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec` [Hermes] Using release tarball from URL: https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.73.4/react-native-artifacts-0.73.4-hermes-ios-debug.tar.gz % Total % Received % Xf erd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 16.2M 100 16.2M 0 0 75.9M 0 --:--: -- --:--:-- --:--:-- 77.2M % Total % Received % Xferd Average Sp eed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 67 12.3M 67 8575k 0 0 67.1M 0 --:--:-- --:--:-- --:--:-- 68.6M 100 12.3M 100 12.3M 0 0 77.0M 0 --: --:-- --:--:-- --:--:-- 78.0M Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/` CocoaPods 1.15.0 is available. To update use: `gem install cocoapods` For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.15.0 Downloading dependencies Installing AppCheckCore (10.18.1) Installing BoringSSL-GRPC (0.0.24) Installing DoubleConversion (1.1.6) Installing EXConstants (15.4.5) Installing EXFont (11.10.3) Installing EXJSONUtils (0.12.3) Installing EXManifests (0.13.2) Installing EXUpdatesInterface (0.15.3) Installing Expo (50.0.8) Installing ExpoFileSystem (16.0.7) Installing ExpoKeepAwake (12.8.2) Installing ExpoModulesCore (1.11.9) Installing FBLazyVector (0.73.4) Installing FBReactNativeSpec (0.73.4) Installing Firebase (10.21.0) Installing FirebaseAppCheck (10.21.0) Installing FirebaseAppCheckInterop (10.21.0) Installing FirebaseAuth (10.21.0) Installing FirebaseAuthInterop (10.21.0) Installing FirebaseCore (10.21.0) Installing FirebaseCoreExtension (10.21.0) Installing FirebaseCoreInternal (10.21.0) Installing FirebaseDatabase (10.21.0) Installing FirebaseFirestore (10.21.0) Installing FirebaseFirestoreInternal (10.21.0) Installing FirebaseFunctions (10.21.0) Installing FirebaseInstallations (10.21.0) Installing FirebaseMessagingInterop (10.21.0) Installing FirebaseSharedSwift (10.21.0) Installing FirebaseStorage (10.21.0) Installing GTMSessionFetcher (3.3.1) Installing GoogleUtilities (7.12.0) Installing PromisesObjC (2.3.1) Installing RCT-Folly (2022.05.16.00) Installing RCTRequired (0.73.4) Installing RCTTypeSafety (0.73.4) Installing RNFBApp (19.0.0) Installing RNFBAppCheck (19.0.0) Installing RNFBAuth (19.0.0) Installing RNFBDatabase (19.0.0) Installing RNFBFirestore (19.0.0) Installing RNFBFunctions (19.0.0) Installing RNFBStorage (19.0.0) Installing React (0.73.4) Installing React-Codegen (0.73.4) Installing React-Core (0.73.4) Installing React-CoreModules (0.73.4) Installing React-Fabric (0.73.4) Installing React-FabricImage (0.73.4) Installing React-ImageManager (0.73.4) Installing React-Mapbuffer (0.73.4) Installing React-NativeModulesApple (0.73.4) Installing React-RCTActionSheet (0.73.4) Installing React-RCTAnimation (0.73.4) Installing React-RCTAppDelegate (0.73.4) Installing React-RCTBlob (0.73.4) Installing React-RCTFabric (0.73.4) Installing React-RCTImage (0.73.4) Installing React-RCTLinking (0.73.4) Installing React-RCTNetwork (0.73.4) Installing React-RCTSettings (0.73.4) Installing React-RCTText (0.73.4) Installing React-RCTVibration (0.73.4) Installing React-callinvoker (0.73.4) Installing React-cxxreact (0.73.4) Installing React-debug (0.73.4) Installing React-graphics (0.73.4) Installing React-hermes (0.73.4) Installing React-jserrorhandler (0.73.4) Installing React-jsi (0.73.4) Installing React-jsiexecutor (0.73.4) Installing React-jsinspector (0.73.4) Installing React-logger (0.73.4) Installing React-nativeconfig (0.73.4) Installing React-perflogger (0.73.4) Installing React-rendererdebug (0.73.4) Installing React-rncore (0.73.4) Installing React-runtimeexecutor (0.73.4) Installing React-runtimescheduler (0.73.4) Installing React-utils (0.73.4) Installing ReactCommon (0.73.4) Installing RecaptchaInterop (100.0.0) Installing SocketRocket (0.6.1) Installing Yoga (1.14.0) Installing abseil (1.20220623.0) Installing boost (1.83.0) Installing expo-dev-client (3.3.9) Installing expo-dev-launcher (3.6.7) Installing expo-dev-menu (4.5.6) Installing expo-dev-menu-interface (1.7.2) Installing fmt (6.2.1) Installing gRPC-C++ (1.49.1) Installing gRPC-Core (1.49.1) Installing glog (0.3.5) Installing hermes-engine (0.73.4) Installing leveldb-library (1.22.3) Installing libevent (2.1.12) Installing nanopb (2.30909.1) Generating Pods project Setting USE_HERMES build settings Setting REACT_NATIVE build settings Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /Users/expo/workingdir/build/ios/reprofirebasepodsissue352024.xcodeproj Pod install took 252 [s] to run Integrating client project [!] Please close any current Xcode sessions and use `reprofirebasepodsissue352024.xcworkspace` for this project from now on. [Expo] Installing the build script for target reprofirebasepodsissue352024 expo_patch_react_imports! took 0.0901 seconds to transform files. Pod installation complete! There are 82 dependencies from the Podfile and 98 total pods installed. [!] `` attempted to initialize an object with an unknown UUID. `86EF150FA91F43ADA7E0CCAD` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded. [!] Can't merge pod_target_xcconfig for pod targets: ["expo-dev-menu", "Main", "ReactNativeCompatibles", "SafeAreaView", "Vendored"]. Singular build setting DEFINES_MODULE has different values. [!] Can't merge pod_target_xcconfig for pod targets: ["expo-dev-menu", "Main", "ReactNativeCompatibles", "SafeAreaView", "Vendored"]. Singular build setting DEFINES_MODULE has different values. [!] hermes-engine has added 1 script phase. Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information. ```

Just to be clear, I believe the build issue isn't because of v10.22.0 but because all of the modules are not on the same version. Absolutely use v10.22.0 as it fixes a runtime issue.

I tried pinning the related modules to v10.22.0 instead but ran into the following build error.

[!] CocoaPods could not find compatible versions for pod "Firebase/Firestore":
  In Podfile:
    RNFBFirestore (from `../node_modules/@react-native-firebase/firestore`) was resolved to 19.0.0, which depends on
      Firebase/Firestore (= 10.21.0)
None of your spec sources contain a spec satisfying the dependency: `Firebase/Firestore (= 10.21.0)`.

Resolving this would requiring patching firebase as described in earlier comments. At that point, you do not need to pin the pods via the config plugin.

I'm asking on the expo discord server if there is a way to add globals to the podfile with a config plugin to implement what @womj suggested. That workaround is better as it does not require knowledge of the exact firebase pods that are installed for any project.

mikehardy commented 8 months ago

Hi there! 👋 Sorry for the delayed response here. I'm qualifying the firebase-ios-sdk 10.22.0 right now for release, but I was under the impression you can easily override the firebase-ios-sdk version as documented here:

https://rnfirebase.io/#ios

...and as mentioned @womj here https://github.com/invertase/react-native-firebase/issues/7666#issuecomment-1980083859 ?

Is there some reason that doesn't work for expo folks to get people moving?

Someone else mentioned that there is a mix of 10.21.0 and 10.22.0 pods coming down when you specify "10.21.0" as the Firebase version, that's because some of the pods are brought in as transitive dependencies and their semver requirement for the transitive dependency allows cocoapods to resolve higher minor version numbers. This is normal, and should not cause problems.

geoffcfchen commented 8 months ago

Hi there! 👋 Sorry for the delayed response here. I'm qualifying the firebase-ios-sdk 10.22.0 right now for release, but I was under the impression you can easily override the firebase-ios-sdk version as documented here:

https://rnfirebase.io/#ios

...and as mentioned @womj here #7666 (comment) ?

Is there some reason that doesn't work for expo folks to get people moving?

Someone else mentioned that there is a mix of 10.21.0 and 10.22.0 pods coming down when you specify "10.21.0" as the Firebase version, that's because some of the pods are brought in as transitive dependencies and their semver requirement for the transitive dependency allows cocoapods to resolve higher minor version numbers. This is normal, and should not cause problems.

I think that for those who use Expo's managed workflow, direct access to iOS and Android native project files is abstracted away, meaning they don't modify the Podfile or any native code directly. This limits the ability to specify or override the Firebase iOS SDK version. In any case, thank you @mikehardy @VictorioMolina for solving this issue.

mikehardy commented 8 months ago

@geoffcfchen I see - I do understand that, I guess I assumed (incorrectly) there would be some sort of Expo plugin somewhere that was fairly standard where you could express the idea "Hey, just add this one raw line to the Podfile at the top" 🤷

Either way, yes, react-native-firebase 19.0.1 is out with @VictorioMolina's PR bumping us to firebase-ios-sdk 10.22.0 in place and it handles the new Xcode's "we issue breaking changes in minor version all the time, enjoy" version update

artem-alek commented 6 months ago

I am still having this issue in April. Just ran into it. Has there been any updates or movement on this? I am about to try the patch package but I dont want to do that...

"@react-native-firebase/app": "^18.9.0", "@react-native-firebase/auth": "^18.9.0", "@react-native-firebase/firestore": "^18.9.0", "@react-native-firebase/storage": "^18.9.0", "expo": "~50.0.17",

artem-alek commented 6 months ago

I am still having this issue in April. Just ran into it. Has there been any updates or movement on this? I am about to try the patch package but I dont want to do that...

"@react-native-firebase/app": "^18.9.0", "@react-native-firebase/auth": "^18.9.0", "@react-native-firebase/firestore": "^18.9.0", "@react-native-firebase/storage": "^18.9.0", "expo": "~50.0.17",

Looks like I resolved this with getting the latest version of react-native-firebase version 19.2.2

vedjuno236 commented 2 months ago

Swift Compiler Error (Xcode): Value of optional type '(any StorageProvider)?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider' /Users/kouved/Booking/User/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:72:11

Swift Compiler Error (Xcode): Value of optional type '(any StorageProvider)?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider' /Users/kouved/Booking/User/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:87:11

Swift Compiler Error (Xcode): Cannot assign value of type '(any AuthInterop)?' to type 'any AuthInterop' /Users/kouved/Booking/User/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:290:38

Swift Compiler Error (Xcode): Cannot assign value of type '(any AppCheckInterop)?' to type 'any AppCheckInterop' /Users/kouved/Booking/User/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:292:46

Uncategorized (Xcode): Command SwiftCompile failed with a nonzero exit code

Could not build the application for the simulator. Error launching application on iPhone 15.

james-zedd4 commented 2 months ago

I ran into the same issue -- [Value of optional type '?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider' ...

I can confirm that updating my version of the firestore apps (18.3.0 -> 20.4.0) fixed the build issue.

Also I am updating my Expo SDK version from 49 -> 51.