React-native-firebase: [BUILD IOS] No known class method for selector 'setAnalyticsCollectionEnabled:'

Created on 21 Jun 2019  路  18Comments  路  Source: invertase/react-native-firebase

This happen when build app in Xcode
Current i'm using
"react-native": "0.59.8",
"react-native-firebase": "^5.5.3",

/Users/xxx/Documents/GitHub/yyy/node_modules/react-native-firebase/ios/RNFirebase/analytics/RNFirebaseAnalytics.m:15:17: No known class method for selector 'setAnalyticsCollectionEnabled:'

iOS No Template Docs

Most helpful comment

You have incompatible version libs in your Pods.
Just going to react-native-firebase version matrix page and choose one for you.

For example:
react-native-firebase: 5.2.x

pod 'Firebase/Core', '~> 5.15.0'

react-native-firebase: 5.5.x

pod 'Firebase/Core', '~> 6.3.0'

All 18 comments

Didn't follow template, and it's a dupe. Unsupported Pod version, you need to upgrade to match the compatibility matrix and follow the release notes indicated via the breaking changes warning.

2272 #2259 etc

try pod install --repo-update. Like @mikehardy said, it's due to mismatch SDK version

i have same issue. does it already solved?

You have incompatible version libs in your Pods.
Just going to react-native-firebase version matrix page and choose one for you.

For example:
react-native-firebase: 5.2.x

pod 'Firebase/Core', '~> 5.15.0'

react-native-firebase: 5.5.x

pod 'Firebase/Core', '~> 6.3.0'

I'm also running into this issue. I'm on RN0.60.4.. and it's not listed in the compatibility matrix.
RN: 0.60.4
Firebase/Core: 6.5.0

Is this correct?

If you are using RN60, please examine this script to see exactly how to construct a working project https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

I'm also running this issue. App does build only via command line but in Xcode it's throwing the following: RNFirebaseAnalytics.m - No known class method for selector 'setAnalyticsCollectionEnabled

Xcode 11
RN 0.59.9
RN Firebase 5.5.1

pod 'Firebase/Core', '~> 5.19.0'
pod 'Firebase/Messaging', '~> 5.19.0'
pod 'Firebase/Storage', '~> 5.19.0'

@dotpegaso this is a very old issue, normally I'd say open a new one with the template but in this case, you're trying to use incompatible versions. My advice in general when I see a selector issue is that you have underlying firebase sdk versions that are too old to have a method we use

It may be that the compatibility matrix here https://rnfirebase.io/docs/v5.x.x/getting-started#Supported-versions---React-Native-/-Firebase is not correct and the versions need to move up

For iOS13 I'd say you really should be on pods 6.8.1 or higher, as those are the ones they finally fixed all the iOS13 issues with.

And I'm not sure why you wouldn't want to be on the latest patch releases at least of your branches? That is, RNFB5.5.6 and RN0.59.10 ?

@mikehardy I've just update RN to 0.59.10, RNFB to 5.5.6 and pods to 6.8.1 as you suggest (I've removed node_modules folder with rm -rf before yarn with the new versions).

react-native run-ios --device via command line works fine, but XCode build still throwing the same error. Can it be some issue with XCode itself?

I've already try close/open it and Product > Clean as well but I dunno if doing only this really solves all possible cache problems or stuff like that, do you know anything that may help me solve this?

Xcode has a bad habit of caching things a little too aggressively leading to odd errors. I use the react-native-clean-project folder to solve this, and I run deep-clean as part of all CI builds and/or when I see a weird error like this

    "deep-clean": "./node_modules/.bin/react-native-clean-project --keep-node-modules --remove-iOS-build --keep-brew --keep-pods --remove-iOS-pods --remove-android-build && yarn clean",
    "clean": "\\rm -fr ./node_modules && \\rm -fr dist/* && \\rm -fr ios/build ios/Pods ios/KScoreApp.xcarchive && \\rm -fr android/build android/app/build",

@mikehardy I've run this clean script but the error persists.

My RNFirebaseAnalytics.m file looks like this:

#import "RNFirebaseAnalytics.h"
#import <React/RCTUtils.h>

#if __has_include(<FirebaseAnalytics/FIRAnalytics.h>)
#import <FirebaseAnalytics/FIRAnalytics.h>

@implementation RNFirebaseAnalytics
RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(logEvent:(NSString *)name props:(NSDictionary *)props) {
  [FIRAnalytics logEventWithName:name parameters:props];
}

RCT_EXPORT_METHOD(setAnalyticsCollectionEnabled:(BOOL) enabled) {
  [FIRAnalytics setAnalyticsCollectionEnabled:enabled];
}

RCT_EXPORT_METHOD(setCurrentScreen:(NSString *) screenName screenClass:(NSString *) screenClassOverriew) {
  RCTUnsafeExecuteOnMainQueueSync(^{
    [FIRAnalytics setScreenName:screenName screenClass:screenClassOverriew];
  });
}

RCT_EXPORT_METHOD(setUserId: (NSString *) id) {
  [FIRAnalytics setUserID:id];
}

RCT_EXPORT_METHOD(setUserProperty: (NSString *) name value:(NSString *) value) {
  [FIRAnalytics setUserPropertyString:value forName:name];
}

// not implemented on iOS sdk
RCT_EXPORT_METHOD(setMinimumSessionDuration:(nonnull NSNumber *) milliseconds) {}
RCT_EXPORT_METHOD(setSessionTimeoutDuration:(nonnull NSNumber *) milliseconds) {}
@end

#else
@implementation RNFirebaseAnalytics
@end
#endif

The error points to this specific line:

RCT_EXPORT_METHOD(setAnalyticsCollectionEnabled:(BOOL) enabled) {
  [FIRAnalytics setAnalyticsCollectionEnabled:enabled];
}

I did the update and stuff but I'm feeling in complete darkness about this issue. :(

Open a new issue following the template then - it'll be a full examination. I will submit that it is something project-specific in either your mix of versions or in your config files, as I prove (both for myself, while troubleshooting or adding features to my work project, plus to others) that it works via this script - which is working for RN59 - I just tested it: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-rn59.sh

I'm facing the same issue. I have checked the compatibility matrix and it is correct.

react-native-firebase ^5.2.5
react-native 0.58.6
Ios Firebase SDK ~> 5.15.0

please paste in the exact build error or runtime error you have

.../node_modules/react-native-firebase/ios/RNFirebase/analytics/RNFirebaseAnalytics.m:15:17: error: no known class method for selector 'setAnalyticsCollectionEnabled:'
[FIRAnalytics setAnalyticsCollectionEnabled:enabled];
^~~~~~~~~
1 error generated.

Added in pods 5.19 - you will have to upgrade, and we need an edit to the version compatibility table https://firebase.google.com/support/release-notes/ios#version_5190_-_march_19_2019 - because it says RNFB5.2.x is compatible with pods up to 5.18.x but clearly it's using a 5.19+ symbol

Really though - if you don't upgrade to react-native 0.59 you aren't 64-bit so the Play Store won't accept updates in just a couple weeks. And once you are on 0.59 you can go to pods >= 6.8.1 which is good because the App Store is giving warnings they will not accept builds with UIWebView symbols and the firebase ios sdks didn't fix that until 6.8.1. Staying current is a pain but it is useful

I would move to react-native 0.59.10 (not a hard move from 0.58), and get react-native-firebase to 5.5.6 and pods to 6.9.0

That react-native build is old enough you may not have seen the new upgrade tools - they came into existence from community effort during the 0.59.x series. Check this out - it helps you get upgraded, for example my recommendation: https://react-native-community.github.io/upgrade-helper/?from=0.58.6&to=0.59.10

Was this page helpful?
0 / 5 - 0 ratings