React-native-fcm: FirebaseCore/FIRApp.h' file not found

Created on 6 Oct 2017  路  22Comments  路  Source: evollu/react-native-fcm

Upgrading to version 10.0.0 (from a quite an older version), iOS build failed with the following error:

xxxxxx/node_modules/react-native-fcm/ios/RNFIRMessaging.m:1:
xxxxxx/node_modules/react-native-fcm/ios/RNFIRMessaging.h:4:9: fatal error: 'FirebaseCore/FIRApp.h' file not found
#import <FirebaseCore/FIRApp.h>
        ^
1 error generated.

This affects debug builds only.

I believe the that the cause is framework/header search paths in RNFIRMessaging.xcodeproj/project.pbxproj:

                FRAMEWORK_SEARCH_PATHS = (
                    "$(inherited)",
                    "$(PROJECT_DIR)/../../../ios/Pods/**",
                    "$(SRCROOT)/../../../node_modules/react-native-firestack/ios/**",
                );
                GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
                HEADER_SEARCH_PATHS = (
                    "$(SRCROOT)/../../react-native/React/**",
                    "$(PROJECT_DIR)/../../../ios/Pods/**",
                    "$(SRCROOT)/../../../node_modules/react-native-firestack/ios/**",

while in Release scheme it is set to this:

                FRAMEWORK_SEARCH_PATHS = (
                    "$(inherited)",
                    "$(PROJECT_DIR)/../../../ios/**",
                    "$(SRCROOT)/../../../node_modules/react-native-firestack/ios/**",
                );
                HEADER_SEARCH_PATHS = (
                    "$(SRCROOT)/../../react-native/React/**",
                    "$(SRCROOT)/../../../ios/**",
                    "$(SRCROOT)/../../../node_modules/react-native-firestack/ios/**",
                );

This configuration assumes usage of Cocoapods.

Changing "$(PROJECT_DIR)/../../../ios/Pods/**" to the more universal "$(PROJECT_DIR)/../../../ios/**" as in the Release scheme fixes this issue

Most helpful comment

@sibelius Move all your Firebase SDK into /ios/Pods folder. it is not working for you?

All 22 comments

Same problem. Thanks! 馃憤

The change was made on purpose to avoid other issues and that folder is too general.
You can just move the file inside Pods folder.

Looks I missed changing release build folder, will fix that one

Which file am I supposed to move there? Fixing Pods folder means that non-cocoapods environment is not supported anymore. If ios/* is too general, then how about adding ios/Frameworks/* to search paths?

Move all your Firebase SDK into /ios/Pods folder. I assume you used a folder called Frameworks to store SDK, just rename it to Pods

we are having the same problem in non-cocapods environment

is there any workaround for now?

@sibelius Move all your Firebase SDK into /ios/Pods folder. it is not working for you?

Now, I'm getting an error on this package https://github.com/evollu/react-native-firebase-analytics

should we update it as well?

@sibelius updated in v4.0.1 there. However there shouldn't be any update required as it is a recursive search

Now it is working, but my app is crashing

I'll try to see what it is happening

2017-10-09 16:08:56.445934-0300 App[49952:4263410] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40004000 started
2017-10-09 16:08:56.449828-0300 App[49952:4263428] +[NSData gtm_dataByGzippingData:error:]: unrecognized selector sent to class 0x111ab0e00
2017-10-09 16:08:56.466036-0300 App[49952:4263428] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSData gtm_dataByGzippingData:error:]: unrecognized selector sent to class 0x111ab0e00'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001117eb1cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010ffb8f41 objc_exception_throw + 48
    2   CoreFoundation                      0x000000011186b854 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x000000011176e178 ___forwarding___ + 1432
    4   CoreFoundation                      0x000000011176db58 _CF_forwarding_prep_0 + 120
    5   App                               0x000000010e61a8e3 -[FIRNetwork postURL:payload:queue:usingBackgroundSession:completionHandler:] + 317
    6   App                               0x000000010e6375d7 -[FIRClearcutLogger sendNextPendingRequestWithCompletionHandler:] + 541
    7   App                               0x000000010e637099 -[FIRClearcutLogger sendLogsWithCompletionHandler:] + 449
    8   libdispatch.dylib                   0x0000000116b1f3f7 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x0000000116b2043c _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x0000000116b2895b _dispatch_queue_serial_drain + 1162
    11  libdispatch.dylib                   0x0000000116b292df _dispatch_queue_invoke + 336
    12  libdispatch.dylib                   0x0000000116b2507d _dispatch_queue_override_invoke + 733
    13  libdispatch.dylib                   0x0000000116b2c1f9 _dispatch_root_queue_drain + 772
    14  libdispatch.dylib                   0x0000000116b2be97 _dispatch_worker_thread3 + 132
    15  libsystem_pthread.dylib             0x0000000116fe71ca _pthread_wqthread + 1387
    16  libsystem_pthread.dylib             0x0000000116fe6c4d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

fixed, it was a missing link on xcode

I resolved this by adding the following to Build Settings => Framework Search Paths in the RNFIRMessaging project:

$(PROJECT_DIR)/../../../ios/Pods/FirebaseCore
$(PROJECT_DIR)/../../../ios/Pods/FirebaseMessaging
$(PROJECT_DIR)/../../../ios/Pods/FirebaseAnalytics
$(PROJECT_DIR)/../../../ios/Pods/FirebaseInstanceID

Note that it's not Header Search Paths since those are for local includes and this is a global include.

This is my fix for solving this problem:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-fcm' then
      target.build_configurations.each do |config|
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] = " $(inherited)"\
                                                          " $(PROJECT_DIR)/FirebaseMessaging/Frameworks"\
                                                          " $(PROJECT_DIR)/FirebaseInstanceID/Frameworks"\
                                                          " $(PROJECT_DIR)/FirebaseCore/Frameworks"

        config.build_settings['OTHER_LDFLAGS'] = "#{config.build_settings['OTHER_LDFLAGS']}"\
                                                 " -framework FirebaseMessaging"\
                                                 " -framework FirebaseInstanceID"\
                                                 " -framework FirebaseCore"
      end
    end
  end
end

(RN 0.50.3 + re-natal 8.0)

@sibelius: How did you manage to resolve the crash? What links did you add in Xcode?
Getting the same crash

when I try to call

RCT_EXPORT_METHOD(getFCMToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
    resolve([FIRMessaging messaging].FCMToken);
}

then I have a crash

2017-12-06 16:27:00.392752+0600 app[69029:9322973] +[FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]: unrecognized selector sent to class 0x1144840d8
2017-12-06 16:27:00.406770+0600 app[69029:9322973] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]: unrecognized selector sent to class 0x1144840d8'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000011627c1cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000115790f41 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001162fc854 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x00000001161ff178 ___forwarding___ + 1432
    4   CoreFoundation                      0x00000001161feb58 _CF_forwarding_prep_0 + 120
    5   react_native_fcm                    0x0000000114425bd9 -[FIRInstanceIDCheckinStore cachedCheckinPreferences] + 407
    6   react_native_fcm                    0x000000011442a399 -[FIRInstanceIDStore cachedCheckinPreferences] + 48
    7   react_native_fcm                    0x0000000114421c13 -[FIRInstanceIDAuthService initWithCheckinService:store:] + 134
    8   react_native_fcm                    0x0000000114421d3e -[FIRInstanceIDAuthService initWithStore:] + 94
    9   react_native_fcm                    0x000000011442ce2a -[FIRInstanceIDTokenManager init] + 160
    10  react_native_fcm                    0x000000011441e487 -[FIRInstanceID setupTokenManager] + 50
    11  react_native_fcm                    0x000000011441e435 -[FIRInstanceID start] + 90
    12  libdispatch.dylib                   0x000000011684a43c _dispatch_client_callout + 8
    13  libdispatch.dylib                   0x000000011684b9c7 dispatch_once_f + 297
    14  react_native_fcm                    0x000000011441bae0 +[FIRInstanceID instanceID] + 45
    15  react_native_fcm                    0x0000000114442a5c __46+[FIRMessagingInstanceIDProxy instanceIDProxy]_block_invoke + 84
    16  libdispatch.dylib                   0x000000011684a43c _dispatch_client_callout + 8
    17  libdispatch.dylib                   0x000000011684b9c7 dispatch_once_f + 297
    18  react_native_fcm                    0x0000000114442a05 +[FIRMessagingInstanceIDProxy instanceIDProxy] + 45
    19  react_native_fcm                    0x0000000114442c05 -[FIRMessagingInstanceIDProxy token] + 40
    20  react_native_fcm                    0x0000000114434d06 -[FIRMessaging FCMToken] + 87
    21  react_native_fcm                    0x0000000114418639 -[RNFIRMessaging getFCMToken:rejecter:] + 137
    22  CoreFoundation                      0x000000011620056c __invoking___ + 140
    23  CoreFoundation                      0x0000000116200440 -[NSInvocation invoke] + 320
    24  CoreFoundation                      0x0000000116218df6 -[NSInvocation invokeWithTarget:] + 54
    25  React                               0x0000000110b9563c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2796
    26  React                               0x0000000110ba1d02 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 786
    27  React                               0x0000000110ba182f _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
    28  React                               0x0000000110ba17a9 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
    29  libdispatch.dylib                   0x00000001168493f7 _dispatch_call_block_and_release + 12
    30  libdispatch.dylib                   0x000000011684a43c _dispatch_client_callout + 8
    31  libdispatch.dylib                   0x000000011685295b _dispatch_queue_serial_drain + 1162
    32  libdispatch.dylib                   0x00000001168532df _dispatch_queue_invoke + 336
    33  libdispatch.dylib                   0x000000011684f07d _dispatch_queue_override_invoke + 733
    34  libdispatch.dylib                   0x00000001168561f9 _dispatch_root_queue_drain + 772
    35  libdispatch.dylib                   0x0000000116855e97 _dispatch_worker_thread3 + 132
    36  libsystem_pthread.dylib             0x0000000116d101ca _pthread_wqthread + 1387
    37  libsystem_pthread.dylib             0x0000000116d0fc4d start_wqthread + 13

who can say what it may be?

what is your firebase sdk version and firebaseinstanceid version?
check your pod.lock @povloid

@evollu

Using Firebase (4.7.0)
Using FirebaseAnalytics (4.0.5)
Using FirebaseCore (4.0.12)
Using FirebaseInstanceID (2.0.7)
Using FirebaseMessaging (2.0.7)

that was when pod install. And also from Pods.lock

- Firebase/Core (4.7.0):
    - FirebaseAnalytics (= 4.0.5)
    - FirebaseCore (= 4.0.12)
  - Firebase/Messaging (4.7.0):
    - Firebase/Core
    - FirebaseMessaging (= 2.0.7)
  - FirebaseAnalytics (4.0.5):
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
    - nanopb (~> 0.3)
  - FirebaseCore (4.0.12):
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
  - FirebaseInstanceID (2.0.7)
  - FirebaseMessaging (2.0.7):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/Logger (~> 2.1)
    - Protobuf (~> 3.1)

pod seems fine, check Capabilities of your app to see if it can access keychain?

try reproduce with example project?

@povloid

Did you fix this error, cause I have the same and I can't figure out whats the problem? Thanks in advance :)

Hello..
Anybody got fix for this?
@ArminSpahic @povloid

At the end I just used apns for the project push notification

Was this page helpful?
0 / 5 - 0 ratings