React-native-fcm: FIRApp undefined after upgrading to 2.1.0

Created on 21 Sep 2016  路  42Comments  路  Source: evollu/react-native-fcm

When i upgrade this package to the latest 2.1.0 (from 2.0.3) i get an error that FIRApp is undefined in the Appdelegate.m file:

[FIRApp configure];

I'm using xcode 8. Have not tried on xcode 7. When i revert back to 2.0.3 the issue is gone.

Most helpful comment

I was having a similar issue
The following commands produced analyzer issues:
Analyze RNFIRMessaging.m
(1 command with analyzer issues)

All 42 comments

same for me when running react-native run-ios:

AppDelegate.m:39:4: error: use of undeclared identifier 'FIRApp'
  [FIRApp configure];
   ^

@antoinerousseau yeah that's indeed the exact error i get. are you also running xcode 8? i assume something is preventing @evollu from getting the same error...

Xcode 7.3

are you using cocoa pods?

i changed import in module from h file to framework, could that be the issue?

i am using cocoapods. what can i change to see if thats the issue?

yes i'm using cocoapods

i will try to create a demo project today
can you give me screenshot of
your appdelegate.m
your pods folder

and have you tried clearing the project and rebuild?

try add @import Firebase in appdelegatr

my AppDeletage.m:

#import "AppDelegate.h"
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>

#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"

#import "RNFIRMessaging.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"tribeez"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  [FIRApp configure];
  [Fabric with:@[[Crashlytics class]]];
  return YES;
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
  fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler
{
  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification];
  handler(UIBackgroundFetchResultNewData);
}

@end

My Pods folder:

capture d ecran 2016-09-21 14 49 01

What do you mean clearing the project?

I'm having the same problem. I made it work by changing +@import Firebase; +@import FirebaseMessaging; inside of ios/rnfirmessage.h to #import "Firebase.h". I don't know if this should be the fix but it worked for me.

it is no long @import Firebase in the code now. Can you get the latest? or I didn't release it?

check v2.1.1

my version had

@import FirebaseInstanceID;
@import FirebaseMessaging;

and it failed with this.

Now I just tried to update to v2.2.0 and I get:

The following commands produced analyzer issues:
    Analyze RNFIRMesssaging.m
(1 command with analyzer issues)

The following build commands failed:
    Analyze RNFIRMesssaging.m
    CompileC /Users/antoine/Sites/tribeez/ios/build/Build/Intermediates/RNFIRMessaging.build/Debug-iphonesimulator/RNFIRMessaging.build/Objects-normal/x86_64/RNFIRMesssaging.o RNFIRMesssaging.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

above this error is a fatal one:

node_modules/react-native-fcm/ios/RNFIRMesssaging.m:8:9: fatal error: module 'UserNotifications' not found
@import UserNotifications;
 ~~~~~~~^~~~~~~~~~~~~~~~~

I'll try to upgrade Xcode from 7 to 8

just installed Xcode 8 and updated my AppDelegate according to latest README.
now I have a bunch of errors (cc @evollu):

/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:28:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitMinute;
           ^~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:31:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitSecond;
           ^~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:34:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitDay;
           ^~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:37:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitMonth;
           ^~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:40:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitWeekOfYear;
           ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:43:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitYear;
           ^~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:63:31: warning: incompatible pointer to integer conversion assigning to 'NSCalendarUnit'
      (aka 'enum NSCalendarUnit') from 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *'); dereference with * [-Wint-conversion]
  notification.repeatInterval = [RCTConvert NSCalendarUnit:details[@"repeat_interval"]];
                              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                *(                                                     )
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:227:43: error: expected a type
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
                                          ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:104:29: error: no visible @interface for 'FIRMessaging' declares the selector
      'setRemoteMessageDelegate:'
  [[FIRMessaging messaging] setRemoteMessageDelegate:self];
   ~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:124:106: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){
                                                                                                         ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:133:95: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getFCMToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
                                                                                              ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:144:12: warning: 11 enumeration values not handled in switch: 'NSCalendarUnitEra',
      'NSCalendarUnitHour', 'NSWeekCalendarUnit'... [-Wswitch]
    switch(notif.repeatInterval){
           ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:138:114: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getScheduledLocalNotifications:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
                                                                                                                 ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:186:28: warning: 'sendDeviceEventWithName:body:' is deprecated: Subclass RCTEventEmitter instead
      [-Wdeprecated-declarations]
  [_bridge.eventDispatcher sendDeviceEventWithName:@"FCMTokenRefreshed" body:[[FIRInstanceID instanceID] token]];
                           ^
In file included from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:5:
../../react-native/React/Base/RCTEventDispatcher.h:70:1: note: 'sendDeviceEventWithName:body:' has been explicitly marked deprecated here
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:216:31: warning: unused parameter 'granted' [-Wunused-parameter]
     completionHandler:^(BOOL granted, NSError * _Nullable error) {
                              ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:216:60: warning: unused parameter 'error' [-Wunused-parameter]
     completionHandler:^(BOOL granted, NSError * _Nullable error) {
                                                           ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:228:96: error: no known instance method for selector 'appData'
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]];
                                                                                               ^~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:228:28: warning: 'sendDeviceEventWithName:body:' is deprecated: Subclass RCTEventEmitter instead
      [-Wdeprecated-declarations]
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]];
                           ^
In file included from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:5:
../../react-native/React/Base/RCTEventDispatcher.h:70:1: note: 'sendDeviceEventWithName:body:' has been explicitly marked deprecated here
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:269:57: warning: incompatible pointer to integer conversion sending 'NSInteger *' (aka 'long *') to
      parameter of type 'NSInteger' (aka 'long'); dereference with * [-Wint-conversion]
  [RCTSharedApplication() setApplicationIconBadgeNumber:number];
                                                        ^~~~~~
                                                        *
In module 'UIKit' imported from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMessaging.h:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:161:32: note:
      passing argument to parameter 'applicationIconBadgeNumber' here
@property(nonatomic) NSInteger applicationIconBadgeNumber;  // set to 0 to hide. default is 0. In iOS 8.0 and later, your application must register for user notifications us...
                               ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:272:99: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
                                                                                                  ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:281:28: warning: 'sendDeviceEventWithName:body:' is deprecated: Subclass RCTEventEmitter instead
      [-Wdeprecated-declarations]
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:data];
                           ^
In file included from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:5:
../../react-native/React/Base/RCTEventDispatcher.h:70:1: note: 'sendDeviceEventWithName:body:' has been explicitly marked deprecated here
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
^
18 warnings and 3 errors generated.

...

/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:227:43: error: expected a type
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
                                          ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:104:29: error: no visible @interface for 'FIRMessaging' declares the selector
      'setRemoteMessageDelegate:'
  [[FIRMessaging messaging] setRemoteMessageDelegate:self];
   ~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:228:96: error: no known instance method for selector 'appData'
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]];
                                                                                               ^~~~~~~

@antoinerousseau

[[FIRMessaging messaging] setRemoteMessageDelegate:self];

is introduced in latest firebase SDK. try update your pods
also try clear your build?

@import UserNotifications; is introduced with iOS10 SDK. Why do you get this error?

how do you clear your build?

i'll look at your repo and try to fix it @antoinerousseau

@antoinerousseau run pod update. you are still using 3.5.x firebase SDK. I downloaded your app and updated pod, build success.
do you mind if i use your repo as demo example since it is public?

@tijs try latest version. I made a fix for your issue

@evollu thanks i will!

@evollu sure you can use it :)
thanks!

@evollu so running pod update indeed fixed this issue :)

and there is a little typo in the doc:
search for + +, it should be a space (in "Shared steps">"Edit AppDelegate.m")

@evollu yup that seems to have fixed it. thanks a lot! (feel free to close it i guess)

@evollu help me :(, this is mine :

screen shot 2016-10-07 at 6 55 28 pm

screen shot 2016-10-07 at 6 55 11 pm

``` ^
/Volumes/Data Storage/Bizzon/project/up-mobile/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:227:43: error: expected a type

  • (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
    ^
    /Volumes/Data Storage/Bizzon/project/up-mobile/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:104:29: error: no visible @interface for 'FIRMessaging' declares the selector 'setRemoteMessageDelegate:'
    [[FIRMessaging messaging] setRemoteMessageDelegate:self];

/Volumes/Data Storage/Bizzon/project/up-mobile/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:228:96: error: no known instance method for selector 'appData'
[_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]];

3 errors generated.
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

```

@trathailoi I was having a similar issue in here https://github.com/evollu/react-native-fcm/issues/163 and I solved it. (yet I'm stuck in another place, now)

I was having a similar issue
The following commands produced analyzer issues:
Analyze RNFIRMessaging.m
(1 command with analyzer issues)

Exactly the same error as @Kalyani518

The following commands produced analyzer issues:

    Analyze RNFIRMessaging.m
(1 command with analyzer issues)

try update your pods?
looks like the firebase lib is not linked correctly

I don't use pods. I linked it manually with the "Non Cocoapod approach" from the Docs. Is there anything special I should check for when manually linking firebase?

have you dragged those frameworks into the solution and referenced them?
what version of FIRMessaging SDK are you using?

I removed all firebase libraries and added them again, just to be sure.

This is how I added them: I dragged the 4 Libraries from the Analytics Directory and the 2 Libraries from the Messaging Directory into the Project Navigator Pane from xcode, respectively into the Frameworks Directory (with "copy items if needed" checked). This adds the *.framework files directly into my-reactnative-project/ios directory. I don't have a directory called my-reactnative-project/ios/frameworks.

If I look in Xcode at Targets > MyProject > Build Phases > Link Binary with Libraries, all 6 Frameworks are listed, also libRNFIRMessaging.a is at the end of the list.

Then I cleared the project (CMD-Shift-K), just to keep things clean after all those changes.

After that, I build the project inside xcode, just to test if it would build. This fails with 'FirebaseCode/FIRApp.h' file not found (RNFIRMessaging.h).

If I run react-native run-ios, it fails with:

The following commands produced analyzer issues:
    Analyze RNFIRMessaging.m
(1 command with analyzer issues)

The following build commands failed:
    CompileC build/Build/Intermediates/REDACTED.build/Debug-iphonesimulator/REDACTED.build/Objects-normal/x86_64/AppDelegate.o REDACTED/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

I really appreciate your help.

Additional info: I also linked it the module with react-native link react-native-fcm

More info: Sometimes react-native run-ios also fails with

In file included from /Users/timomaemecke/Documents/dev/REDACTED/ios/REDACTED/AppDelegate.m:11:
/Users/timomaemecke/Documents/dev/REDACTED/ios/../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.

(Sorry for spamming info's here, I'm just trying to give as much information as possible)

can you check framework search path of RNFIRMessaging project? I have $(PROJECT_DIR)/../../../ios there but wonder it includes the place you put your framework file

Framework Search Path inside node_modules/react-native-fcm/ios/RNFIRMessaging.xcodeproj/project.pbxproj is

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

I solved it somehow. I copied the framework files into ~/Documents/FirebaseSDK and added this path to the Any SDK Section inside the Framework Search Paths of my project.

image

react-native-fbsdk does the same thing.

I don't think that's a very pretty solution, but the app builds, so I'm fine with it. 馃槄

it will break next time you install the package. like in CI?
so seems the issue is the path is not correctly set. can you verify that your SDK file is inside$(PROJECT_DIR)/../../../ios/**? try put these files in a subfolder of ios folder?

I tried everything. Can verify the frameworks are there. We tried to build it on the machine of a colleague and it worked without problems, so that's our solution for now.

OK.

Was this page helpful?
0 / 5 - 0 ratings