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

[πŸ›] @react-native-firebase/firestore fails to build on Xcode 16 - BoringSSL-GRPC issue unsupported option '-G' #8020

Closed alfjesus closed 1 month ago

alfjesus commented 1 month ago

Issue

Getting the following "unsupported option -G" build error when trying to build with Expo 51 and Xcode 16. I'm guessing that the dependency for pod BoringSSL-GRPC needs an update. CleanShot 2024-09-17 at 10 35 22@2x


Project Files

Javascript

Click To Expand

#### `package.json`: ```json # N/A ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


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`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 15.0 CPU: (12) arm64 Apple M2 Pro Memory: 465.64 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 20.17.0 path: /var/folders/jn/92972fv55qdc10m6nk8nps3w0000gn/T/yarn--1726562737749-0.4741444639345749/node Yarn: version: 1.22.21 path: /var/folders/jn/92972fv55qdc10m6nk8nps3w0000gn/T/yarn--1726562737749-0.4741444639345749/yarn npm: version: 10.8.2 path: /opt/homebrew/opt/node@20/bin/npm Watchman: version: 2024.07.08.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 24.0 - iOS 18.0 - macOS 15.0 - tvOS 18.0 - visionOS 2.0 - watchOS 11.0 Android SDK: Not Found IDEs: Android Studio: 2023.2 AI-232.10300.40.2321.11567975 Xcode: version: 16.0/16A242d path: /usr/bin/xcodebuild Languages: Java: version: 17.0.10 path: /usr/bin/javac Ruby: version: 2.6.10 path: /usr/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.74.5 wanted: 0.74.5 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true 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:** - `20.5.0` - **`Firebase` module(s) you're using that has the issue:** - `firestore` - **Are you using `TypeScript`?** - `Y` & `5.3.3`


joaqo commented 1 month ago

Same here.

itsjustjo96 commented 1 month ago

Same for me. Apparently this issue was fixed in BoringSSL 0.36.

https://github.com/grpc/grpc/pull/36904

itsjustjo96 commented 1 month ago

This fix indeed seems to work. Adding this code piece to the podfile and then reinstalling the pods is a temporary fix.

https://stackoverflow.com/a/78633109

alfjesus commented 1 month ago

This fix indeed seems to work. Adding this code piece to the podfile and then reinstalling the pods is a temporary fix.

https://stackoverflow.com/a/78633109

@itsjustjo96 Yes, that fix works. However, when using Expo Prebuild i.e CNG (Continuous Native Generation ), the podfile gets overwritten every time.

russellwheatley commented 1 month ago

Thank you for the workaround, @itsjustjo96 πŸ™ . Unfortunately, I'll be away for a week. If there is someone who is able to raise a PR in the meanwhile, I can take a look when I get back. Otherwise, I can get a fix up next week πŸ‘

mikehardy commented 1 month ago

Upstream firebase-ios-sdk specifies a version range for the transitive gRPC dependency with the problem:

https://github.com/firebase/firebase-ios-sdk/blob/b5e2c182c83db543829f2a712f5cff7e6ad1ce1e/FirebaseFirestoreInternal.podspec#L107-L108

Here's the upstream issue https://github.com/firebase/firebase-ios-sdk/issues/13115

When I do a fresh install using firebase-ios-sdk 11.2.0 it works to bring in a version of gRPC with the fix, that is a gRPC with version >= 1.65.2:

run pod install and check output, here's a snippet:

Installing gRPC-C++ (1.65.5) Installing gRPC-Core (1.65.5)

gRPC and Firestore compile fine for me

So I do not believe this is an issue. You may need to remove your Podfile.lock and reinstall Pods to get the updated transitive dependency?

mikehardy commented 1 month ago

Note that if you are using the pre-compiled / binary Firebase from firestore-ios-sdk-frameworks they do not appear to have the fix but that is not a bug in react-native-firebase, it should be logged tracked over there.

Appears they are still on gRPC 1.65.1 which does not have the fix: https://github.com/search?q=repo%3Ainvertase%2Ffirestore-ios-sdk-frameworks+gRPC&type=code

A workaround would be to deintegrate the pre-compiled version and build firestore from current source with current transitive deps, and if compile speed is an issue you might try ccache

alfjesus commented 1 month ago

@mikehardy If I spawn up a new Expo project and add @react-native-firebase/firestore the same build failure is happening so I think this is still an issue?

mikehardy commented 1 month ago

@alfjesus I don't use Expo so I cannot comment. I build things from scratch in order to make my assertions though, and I cannot reproduce - my build rig: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

(I have local changes in that one to do the test, but it shows what I'm doing - init of bare react-native project, scripted integration of react-native-firebase, build test)

alfjesus commented 1 month ago

@mikehardy Okay I see. It's just that my Expo project was building fine on Xcode 15.4 and as soon I upgraded to Xcode 16 this build issue started to happen.

mikehardy commented 1 month ago

I believe I see the problem - just noticed that react-native-firebase hasn't adopted firebase-ios-sdk v11+ yet

It is only in firebase-ios-sdk v11+ that the gRPC version was updated, you can see the commit that did the bump and expand the tag list to see it is only SDK v11+ tags: https://github.com/firebase/firebase-ios-sdk/commit/89a0ab37724c4c5609ee7e61fd347b75102f5a32

My build rig specifically overrides firebase-ios-sdk in order to compile test with newer versions in order to find problems before users do, but that means it doesn't always see problems with interop in older versions

Unfortunately if you use firebase-ios-sdk v11+ via an override, you'll have a new problem which is that the crashlytics init provider API signature upstream changed and is not compatible across the firebase-ios-sdk v10 / v11 boundary

https://github.com/invertase/react-native-firebase/blob/480947eeb6bf5a61c0469b37e93911d9daa4958a/packages/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m#L137

(with a local patch that implements #8025, and a patch that implements #8021 which I just posted, firebase-ios-sdk v11.2.0 appears to work fine with gRPC and crashlytics in build testing at least)

alfjesus commented 1 month ago

@mikehardy Nice to hear that you have nailed down the root cause of the issue. Hopefully react-native-firebase can be adotped soon to use firebase-ios-sdk v11+. I believe that the number of users impacted by this issue will increase by every day that passed by when people upgrade to Xcode 16, unaware of this issue. Rollback is also not so easy since after upgrading to Xcode 16 on MacOS Sequoia, you can't roll back to Xcode 15.4.

alfjesus commented 1 month ago

Figured out a temporary patch to adopt in firebase-ios-sdk v11+. Builds successfully after patching.

Attaching the patch files @react-native-firebase+firestore+20.5.0.patch @react-native-firebase+app+20.5.0.patch

mikehardy commented 1 month ago

If you need crashlytics and firebase-ios-sdk v11+ you'll also want this:

diff --git a/node_modules/@react-native-firebase/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m b/node_modules/@react-native-firebase/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m
index b815df9..4e4961d 100644
--- a/node_modules/@react-native-firebase/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m
+++ b/node_modules/@react-native-firebase/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m
@@ -134,7 +134,6 @@ NSString *const KEY_CRASHLYTICS_JAVASCRIPT_EXCEPTION_HANDLER_CHAINING_ENABLED =
   FIRComponent *crashlyticsInitProvider =
       [FIRComponent componentWithProtocol:@protocol(RNFBCrashlyticsInitProviderProtocol)
                       instantiationTiming:FIRInstantiationTimingEagerInDefaultApp
-                             dependencies:@[]  // note this will go away in firebase-ios-sdk v11+
                             creationBlock:creationBlock];

   return @[ crashlyticsInitProvider ];

(I have it as patches/@react-native-firebase+crashlytics+20.5.0.patch) --> https://github.com/mikehardy/rnfbdemo/blob/main/patches/%40react-native-firebase%2Bcrashlytics%2B20.5.0.patch

oskarnellfors commented 1 month ago

Thank you! πŸ™ I just want to confirm that with these 3 patches our Expo-project now builds again. πŸŽ‰

tibbe commented 1 month ago

Anyone know how to patch @react-native-firebase/messaging similar to the above?

IbraheemShawhnee commented 1 month ago

any updates on this? Becuase this issue has been appear when i update xcode from 15.0 to 16.0 i got clang: error: unsupported option '-G' for target 'arm64-apple-ios13.4-simulator'

enmanuelmag commented 1 month ago

Facing the same problem here. Hopping that react-native-firebase release a new version with the fix.

mikehardy commented 1 month ago

Hey everyone! πŸ‘‹

+1s, reports that it is also affecting you: that does not help it really makes the issue hard to read for others that want a workaround

The workaround right now is to patch react-native-firebase with the above patches:

And then we have to wait for an official release

If you subscribe to this issue using the button on the right of the github web UI you will be notified when it is closed so you know there is new information

Until then, we all have to use the patches or wait for a release.

terrafant commented 1 month ago

This fix indeed seems to work. Adding this code piece to the podfile and then reinstalling the pods is a temporary fix.

https://stackoverflow.com/a/78633109

For Expo project this solution works for me:

  1. Add withBoringSSLFix.js to the root of the project:
    
    // withBoringSSLFix.js

const { withDangerousMod } = require('@expo/config-plugins'); const fs = require('fs'); const path = require('path');

const withBoringSSLFix = (config) => { return withDangerousMod(config, [ 'ios', (config) => { const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile'); let podfileContents = fs.readFileSync(podfilePath, 'utf-8');

  //  Fix for the Podfile
  const fix = `

pre_install do |installer| installer.pod_targets.each do |pod| if pod.name.eql?('BoringSSL-GRPC') def pod.build_type; Pod::BuildType.static_library end end end end `;

  // Adding the fix before the first 'post_install' occurrence
  if (!podfileContents.includes("pod.name.eql?('BoringSSL-GRPC')")) {
    const postInstallIndex = podfileContents.indexOf('post_install do |installer|');
    if (postInstallIndex !== -1) {
      podfileContents = podfileContents.slice(0, postInstallIndex) + fix + podfileContents.slice(postInstallIndex);
    } else {
      // If there's no post_install, append the fix at the end
      podfileContents += fix;
    }
    fs.writeFileSync(podfilePath, podfileContents);
  }

  return config;
},

]); };

module.exports = withBoringSSLFix;

2. Update app.config.js (or if you don't have app.config.js, then convert app.json to app.config.js):

import withBoringSSLFix from './withBoringSSLFix';

export default { expo: { //... expo configs plugins: [ // ... other existing plugins withBoringSSLFix, ]} }


3. Regenerate the native iOS project
`npx expo prebuild -p ios --clean` 
4. Run iOS project:
`npx expo run:ios`
alfjesus commented 1 month ago

This fix indeed seems to work. Adding this code piece to the podfile and then reinstalling the pods is a temporary fix. https://stackoverflow.com/a/78633109

For Expo project this solution works for me:

  1. Add withBoringSSLFix.js to the root of the project:
// withBoringSSLFix.js

const { withDangerousMod } = require('@expo/config-plugins');
const fs = require('fs');
const path = require('path');

const withBoringSSLFix = (config) => {
  return withDangerousMod(config, [
    'ios',
    (config) => {
      const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
      let podfileContents = fs.readFileSync(podfilePath, 'utf-8');

      //  Fix for the Podfile
      const fix = `
  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('BoringSSL-GRPC')
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end
`;

      // Adding the fix before the first 'post_install' occurrence
      if (!podfileContents.includes("pod.name.eql?('BoringSSL-GRPC')")) {
        const postInstallIndex = podfileContents.indexOf('post_install do |installer|');
        if (postInstallIndex !== -1) {
          podfileContents = podfileContents.slice(0, postInstallIndex) + fix + podfileContents.slice(postInstallIndex);
        } else {
          // If there's no post_install, append the fix at the end
          podfileContents += fix;
        }
        fs.writeFileSync(podfilePath, podfileContents);
      }

      return config;
    },
  ]);
};

module.exports = withBoringSSLFix;
  1. Update app.config.js (or if you don't have app.config.js, then convert app.json to app.config.js):
import withBoringSSLFix from './withBoringSSLFix';

export default {
  expo: {
    //... expo configs
     plugins: [
  // ... other existing plugins
  withBoringSSLFix,
   ]}
}
  1. Regenerate the native iOS project npx expo prebuild -p ios --clean
  2. Run iOS project: npx expo run:ios

This fix indeed seems to work. Adding this code piece to the podfile and then reinstalling the pods is a temporary fix. https://stackoverflow.com/a/78633109

For Expo project this solution works for me:

  1. Add withBoringSSLFix.js to the root of the project:
// withBoringSSLFix.js

const { withDangerousMod } = require('@expo/config-plugins');
const fs = require('fs');
const path = require('path');

const withBoringSSLFix = (config) => {
  return withDangerousMod(config, [
    'ios',
    (config) => {
      const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
      let podfileContents = fs.readFileSync(podfilePath, 'utf-8');

      //  Fix for the Podfile
      const fix = `
  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('BoringSSL-GRPC')
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end
`;

      // Adding the fix before the first 'post_install' occurrence
      if (!podfileContents.includes("pod.name.eql?('BoringSSL-GRPC')")) {
        const postInstallIndex = podfileContents.indexOf('post_install do |installer|');
        if (postInstallIndex !== -1) {
          podfileContents = podfileContents.slice(0, postInstallIndex) + fix + podfileContents.slice(postInstallIndex);
        } else {
          // If there's no post_install, append the fix at the end
          podfileContents += fix;
        }
        fs.writeFileSync(podfilePath, podfileContents);
      }

      return config;
    },
  ]);
};

module.exports = withBoringSSLFix;
  1. Update app.config.js (or if you don't have app.config.js, then convert app.json to app.config.js):
import withBoringSSLFix from './withBoringSSLFix';

export default {
  expo: {
    //... expo configs
     plugins: [
  // ... other existing plugins
  withBoringSSLFix,
   ]}
}
  1. Regenerate the native iOS project npx expo prebuild -p ios --clean
  2. Run iOS project: npx expo run:ios

@terrafant Even though your fix works, I don't understand why this option is preferable compared to patches? I mean once a new version of react-native-firebase is out, you will need to modify app.config.js again to remove the fix. A patch on the other hand is only bound and applied to a specific version, hence no code change is necessary when a new release is out.

terrafant commented 1 month ago

@alfjesus because this way I don't have to reapply patches again if I need to redo npm install

alfjesus commented 1 month ago

@alfjesus because this way I don't have to reapply patches again if I need to redo npm install

https://github.com/ds300/patch-package to the rescue! This is want I use. Applies patches automatically every time you do npm install

mikehardy commented 1 month ago

It may be that adopting new versions requires some sort of coordination / certification process for users such that even a release of react-native-firebase does not really help them quickly as someone may not be able to adopt it, and patches may not be allowed for certification reasons too 🀷 .

So I appreciate the Expo plugin workaround from @terrafant even if I also personally use + love the patch-package module.

You never know which workaround people will need.

I believe the fixes required to adopt firebase-ios-sdk v11+ are in process though and there will be a release soon.

Until then, patch it, do a plugin, whichever works but hopefully everyone is able to continue working despite the yearly disruption that is the Xcode release day :-)

PavelShev commented 1 month ago

same here. ReactNative CLI Edit the Podfile, and the project started build like a charm

post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'BoringSSL-GRPC'
        target.source_build_phase.files.each do |file|
          if file.settings && file.settings['COMPILER_FLAGS']
            flags = file.settings['COMPILER_FLAGS'].split
            flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
            file.settings['COMPILER_FLAGS'] = flags.join(' ')
          end
        end
      end
    end
    $RNMapboxMaps.post_install(installer)
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )
  end
end
ArGeoph commented 1 month ago

same here. ReactNative CLI Edit the Podfile, and the project started build like a charm

post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'BoringSSL-GRPC'
        target.source_build_phase.files.each do |file|
          if file.settings && file.settings['COMPILER_FLAGS']
            flags = file.settings['COMPILER_FLAGS'].split
            flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
            file.settings['COMPILER_FLAGS'] = flags.join(' ')
          end
        end
      end
    end
    $RNMapboxMaps.post_install(installer)
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )
  end
end

Thanks a lot! Saved me many hours on debugging πŸ˜ƒ

dibasdauliya commented 1 month ago

nothing is working for me. getting same error every time. :(

β€Ί Compiling @react-native-firebase/firestore Pods/BoringSSL-GRPC Β» tls_record.cc

❌  clang: error: unsupported option '-G' for target 'arm64-apple-ios13.4-simulator'
dibasdauliya commented 1 month ago

inside app > package.json, it shows old version of firebase SDK

image

is it because of that?

anhtuank7c commented 1 month ago

same here. ReactNative CLI Edit the Podfile, and the project started build like a charm

post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'BoringSSL-GRPC'
        target.source_build_phase.files.each do |file|
          if file.settings && file.settings['COMPILER_FLAGS']
            flags = file.settings['COMPILER_FLAGS'].split
            flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
            file.settings['COMPILER_FLAGS'] = flags.join(' ')
          end
        end
      end
    end
    $RNMapboxMaps.post_install(installer)
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )
  end
end

This fix also work for me with Expo project.

anhtuank7c commented 1 month ago

I am using Expo so I modify the fix script like this:

# withBoringSSLFix.js

const { withDangerousMod } = require('@expo/config-plugins');
const fs = require('fs');
const path = require('path');

const withBoringSSLFix = (config) => {
  return withDangerousMod(config, [
    'ios',
    (config) => {
      const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
      let podfileContents = fs.readFileSync(podfilePath, 'utf-8');

      //  Fix for the Podfile
      const fix = `

    # Fix BoringSSL-GRPC issue unsupported option '-G'
    # Reason: BoringSSL-GRPC doesn't compatible with Xcode 16
    # https://github.com/invertase/react-native-firebase/issues/8020?fbclid=IwY2xjawFc9KxleHRuA2FlbQIxMQABHenJMPNnLPuWcojthZjTcuIvoSKes2ATG69IuneRy2bUjAH3J2nYr-5nlQ_aem_XnJhQUj0eNzBy5xl6kjfmw#issuecomment-2359198907
    installer.pods_project.targets.each do |target|
      if target.name == 'BoringSSL-GRPC'
        target.source_build_phase.files.each do |file|
          if file.settings && file.settings['COMPILER_FLAGS']
            flags = file.settings['COMPILER_FLAGS'].split
            flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
            file.settings['COMPILER_FLAGS'] = flags.join(' ')
          end
        end
      end
    end
`;
      if (!podfileContents.includes("if target.name == 'BoringSSL-GRPC'")) {
        const findString = 'post_install do |installer|';
        const postInstallIndex = podfileContents.indexOf(findString);
        if (postInstallIndex !== -1) {
          podfileContents =
            podfileContents.slice(0, postInstallIndex + findString.length) +
            fix +
            podfileContents.slice(postInstallIndex + findString.length);
        }
        fs.writeFileSync(podfilePath, podfileContents);
      }

      return config;
    },
  ]);
};

module.exports = withBoringSSLFix;
dennisofficial commented 1 month ago

Above works great

mikehardy commented 1 month ago

Released this morning, current RNFB should work with current Xcode once again

alfjesus commented 1 month ago

Great work @mikehardy and anyone else involved in the fix πŸ‘

alifa20 commented 1 month ago

That's amazing news! @mikehardy Well done

tboba commented 1 month ago

@mikehardy After updating RNFB libraries to 21.0.0, I'm still getting the same error about BoringSSL-GRPC library in Xcode. I've already cleaned build folder (via Build -> Clean Build Folder option in Xcode), removed node_modules and even deintegrated pods. Are there any additional steps I need to do after the upgrade, or maybe I'm doing something wrong? πŸ€”

CleanShot 2024-10-07 at 19 44 03@2x

mikehardy commented 1 month ago

@tboba not enough information to say, but this could happen if you are overriding the firebase iOS sdk in podfile. My build demonstrator at GitHub mikehardy/rnfbdemo has no problem showing successful build now

tboba commented 1 month ago

@mikehardy Yup! Changing manually version of FirebaseCore was the culprit here. Thanks for the hint!

Emmanueldmlr commented 1 month ago
image

Who knows how to fix this?

mikehardy commented 1 month ago

@Emmanueldmlr I believe all the fixes are documented in this issue. If you are using current react-native-firebase and remove any firebase-ios-sdk version pins you've placed in Podfile, it will build. If it does not, you have a local project problem

Conclusive proof it works, a start-from-scratch fully automated build demo: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

johhansantana commented 1 week ago

Getting this error:

/path/to/project/node_modules/@react-native-firebase/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m:135:21 No known class method for selector 'componentWithProtocol:instantiationTiming:creationBlock:'

CleanShot 2024-10-29 at 19 21 57

using

"@react-native-firebase/analytics": "21.2.0",
"@react-native-firebase/app": "21.2.0",
"@react-native-firebase/crashlytics": "21.2.0",
"@react-native-firebase/database": "21.2.0",
"@react-native-firebase/messaging": "21.2.0",
"@react-native-firebase/remote-config": "21.2.0",

the patches here have already been implemented in the latest versions from what I could investigate.

I'm using "react-native": "0.72.6" and xcode 16.0

vlsido commented 1 week ago

Getting this error:

/path/to/project/node_modules/@react-native-firebase/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m:135:21 No known class method for selector 'componentWithProtocol:instantiationTiming:creationBlock:'

CleanShot 2024-10-29 at 19 21 57

using

"@react-native-firebase/analytics": "21.2.0",
"@react-native-firebase/app": "21.2.0",
"@react-native-firebase/crashlytics": "21.2.0",
"@react-native-firebase/database": "21.2.0",
"@react-native-firebase/messaging": "21.2.0",
"@react-native-firebase/remote-config": "21.2.0",

the patches here have already been implemented in the latest versions from what I could investigate.

I'm using "react-native": "0.72.6" and xcode 16.0

Same here but using react-native 0.73.4 and xcode 15.4

mikehardy commented 1 week ago

/path/to/project/node_modules/@react-native-firebase/crashlytics/ios/RNFBCrashlytics/RNFBCrashlyticsInitProvider.m:135:21 No known class method for selector 'componentWithProtocol:instantiationTiming:creationBlock:'

You are posting on an unrelated issue, this is not related

You are using an outdated version of firebase-ios-sdk relative to react-native-firebase, we test cross-compatibility so that our code here works with the firebase-ios-sdk version we specify in @react-native-firebase/app package.json

If you pin your firebase-ios-sdk to some other version for any reason, you may see errors like this, and it is why there is a warning that if you pin your version manually you are on your own

Remove any version pins you may have for firebase-ios-sdk rerun pod install and it will build

johhansantana commented 1 week ago

hey @mikehardy I've looked for that firebase-ios-sdk pins but I can't seem to find any configuration that I have made to pin it. My project runs with all the other listed firebase libraries if I don't use the crashlytics one. As soon as I install that one I get the error described.

Wouldn't that mean that this firebase-ios-sdk is correctly configured for the others but not for crashlytics? How come? And how can I go on debugging this?

mikehardy commented 1 week ago

Step 1, verify you are on all consistent + current versions of react-native-firebase:

mike@isabela:~/work/invertase/rnfbdemo/rnfbdemo (main) % cat package.json |grep -i react-native-firebase
    "@react-native-firebase/analytics": "21.2.0",
    "@react-native-firebase/app": "21.2.0",
    "@react-native-firebase/app-check": "21.2.0",
    "@react-native-firebase/app-distribution": "21.2.0",
    "@react-native-firebase/auth": "21.2.0",
    "@react-native-firebase/crashlytics": "21.2.0",
    "@react-native-firebase/database": "21.2.0",
    "@react-native-firebase/dynamic-links": "21.2.0",
    "@react-native-firebase/firestore": "21.2.0",
    "@react-native-firebase/functions": "21.2.0",
    "@react-native-firebase/in-app-messaging": "21.2.0",
    "@react-native-firebase/installations": "21.2.0",
    "@react-native-firebase/messaging": "21.2.0",
    "@react-native-firebase/ml": "21.2.0",
    "@react-native-firebase/perf": "21.2.0",
    "@react-native-firebase/remote-config": "21.2.0",
    "@react-native-firebase/storage": "21.2.0",

2- make sure you either have no pin or it is the correct one:

mike@isabela:~/work/invertase/rnfbdemo/rnfbdemo (main) % cat ios/Podfile |grep -i firebase
  $RNFirebaseAsStaticFramework = true
  $FirebaseSDKVersion = '11.4.2'

Note: that is a version pin. You really should not have one. I have one in rnfbdemo because I test cross-compatibility across different versions and need to pin it to force wrong versions to reproduce errors or to force new versions to make sure we are forward-compatible. But that's what the version pin looks like if it is correct for now, the current release

3- Run yarn or npm install or whatever you need to do to install the javascript packages 4- Run cd ios && rm -f Podfile.lock && pod install --repo-update to make sure you get the right native version 5- verify you have the right native version:

mike@isabela:~/work/invertase/rnfbdemo/rnfbdemo (main) % cat ios/Podfile.lock |grep -i crashlytics
  - Firebase/Crashlytics (11.4.2):
    - FirebaseCrashlytics (~> 11.4.0)
  - FirebaseCrashlytics (11.4.0):
  - RNFBCrashlytics (21.2.0):
    - Firebase/Crashlytics (<= 11.4.2)
  - "RNFBCrashlytics (from `../node_modules/@react-native-firebase/crashlytics`)"
    - FirebaseCrashlytics
  RNFBCrashlytics:
    :path: "../node_modules/@react-native-firebase/crashlytics"
  FirebaseCrashlytics: 41bbdd2b514a8523cede0c217aee6ef7ecf38401
  RNFBCrashlytics: 08d706368909b2996ac605c07ba8be75b54b2e80

mike@isabela:~/work/invertase/rnfbdemo/rnfbdemo (main) % cat ios/Podfile.lock |grep -i firebasecore|sort|uniq
    - FirebaseCore
    - FirebaseCore (= 11.4.2)
    - FirebaseCore (~> 11.0)
    - FirebaseCore (~> 11.4)
    - FirebaseCoreExtension
    - FirebaseCoreExtension (<= 11.4.2)
    - FirebaseCoreExtension (~> 11.4)
    - FirebaseCoreInternal
    - FirebaseCoreInternal (< 12.0, >= 11.4.2)
  - FirebaseCore (11.4.2):
  - FirebaseCoreExtension (11.4.1):
  - FirebaseCoreInternal (11.4.2):
  FirebaseCore: 6b32c57269bd999aab34354c3923d92a6e5f3f84
  FirebaseCoreExtension: f1bc67a4702931a7caa097d8e4ac0a1b0d16720e
  FirebaseCoreInternal: 35731192cab10797b88411be84940d2beb33a238

If you don't see versions that are all 11+ in there, you have problems. What are your problems? Sorry, no idea, but somewhere something must be forcing you to get the wrong firebase-ios-sdk version.

It won't be in this repository a) assuming you are all on react-native-firebase same version, all 21.2.0, and b) assuming you do not have a version pin or if you do it is for v11+

That's all I can say for certainty. There is not a problem in this repository, and we can't offer infinite support for project-specific issues so I likely won't have time to comment further

mikehardy commented 1 week ago

I'm going to hide all these comments as off-topic as they are a hijack of the original issue and clutter up the original issue information for people actually looking. Sorry everyone that was interested in the original issue for the off-topic issue notification spam

hamzalakrati commented 1 week ago

Why is this issue closed, looks like many of us still have the issue.

I am using Expo 51 with "@react-native-firebase/firestore": "^21.2.0", and keep on getting that error:

image
hamzalakrati commented 1 week ago

I am using Expo so I modify the fix script like this:

# withBoringSSLFix.js

const { withDangerousMod } = require('@expo/config-plugins');
const fs = require('fs');
const path = require('path');

const withBoringSSLFix = (config) => {
  return withDangerousMod(config, [
    'ios',
    (config) => {
      const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
      let podfileContents = fs.readFileSync(podfilePath, 'utf-8');

      //  Fix for the Podfile
      const fix = `

    # Fix BoringSSL-GRPC issue unsupported option '-G'
    # Reason: BoringSSL-GRPC doesn't compatible with Xcode 16
    # https://github.com/invertase/react-native-firebase/issues/8020?fbclid=IwY2xjawFc9KxleHRuA2FlbQIxMQABHenJMPNnLPuWcojthZjTcuIvoSKes2ATG69IuneRy2bUjAH3J2nYr-5nlQ_aem_XnJhQUj0eNzBy5xl6kjfmw#issuecomment-2359198907
    installer.pods_project.targets.each do |target|
      if target.name == 'BoringSSL-GRPC'
        target.source_build_phase.files.each do |file|
          if file.settings && file.settings['COMPILER_FLAGS']
            flags = file.settings['COMPILER_FLAGS'].split
            flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
            file.settings['COMPILER_FLAGS'] = flags.join(' ')
          end
        end
      end
    end
`;
      if (!podfileContents.includes("if target.name == 'BoringSSL-GRPC'")) {
        const findString = 'post_install do |installer|';
        const postInstallIndex = podfileContents.indexOf(findString);
        if (postInstallIndex !== -1) {
          podfileContents =
            podfileContents.slice(0, postInstallIndex + findString.length) +
            fix +
            podfileContents.slice(postInstallIndex + findString.length);
        }
        fs.writeFileSync(podfilePath, podfileContents);
      }

      return config;
    },
  ]);
};

module.exports = withBoringSSLFix;

Can you please provide exact steps and your version of Expo & Xcode

mikehardy commented 1 week ago

@hamzalakrati it is closed because it is fixed. We get 534,000+ downloads a week and this was closed 3 weeks ago If it were still a problem for people with correctly configured projects, we would know by now. Also, my fully automated build demonstrator would fail, but it does not, it works: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

So it's fixed but your project has a problem.

Check your Podfile.lock and examing the grpc dependency to make sure it is the right one as mentioned in this comment:

https://github.com/invertase/react-native-firebase/issues/8020#issuecomment-2356606866

Maybe remove your Podfile.lock and pod install again. Make sure you have no firebase-ios-sdk version pins, make sure react-native-firebase is all the same version and all the current version.

stefan-schweiger commented 22 hours ago

@mikehardy I'm on Xcode 16.1 with target 18.1 and get this error for both 21.3.0 and 21.4.0, our CI machine which uses Xcode 16.0 seems to build without a problem. Are you sure that there is no new incompability?

mikehardy commented 21 hours ago

@stefan-schweiger In response to your query I just ran my build repro / demonstrator make-demo.sh right now to confirm everything is building with current tools

It all works fine, from scratch, rnfb 21.4.0, Xcode 16.1 target iOS 18.1 simulator debug and release

success Successfully built the app

Check your Podfile.lock as mentioned https://github.com/invertase/react-native-firebase/issues/8020#issuecomment-2356606866

There are no incompatibilities I'm aware of