React-native-fcm: Build fails in newly generated project

Created on 25 Nov 2017  路  14Comments  路  Source: evollu/react-native-fcm

"react-native": "0.50.3"
After running: react-native link react-native-fcm
My pod file contains this lines:

  pod 'Firebase/Messaging'
  pod 'react-native-fcm', :path => '../node_modules/react-native-fcm'

when trying to pod install:

Installing React (0.11.0)
Using nanopb (0.3.8)
Installing react-native-fcm (10.0.3)
[!] React has been deprecated

then when Im building IOS

In file included from /Users/alex/dev/tandem/node_modules/react-native-fcm/ios/RNFIRMessaging.m:1:
/Users/alex/dev/tandem/node_modules/react-native-fcm/ios/RNFIRMessaging.h:7:9: fatal error: 'React/RCTEventEmitter.h' file not found
#import <React/RCTEventEmitter.h>

if I remove pod 'react-native-fcm', :path => '../node_modules/react-native-fcm'

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RNFIRMessaging", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64

Most helpful comment

I tried manually linking React and yoga

  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"  
  pod 'React', :path => '../node_modules/react-native'
  pod 'react-native-fcm', :path => '../node_modules/react-native-fcm'

and looks like it solved the build problem, now have to check if it also works
EDIT:
@evollu Can you please look at this issue

All 14 comments

I tried manually linking React and yoga

  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"  
  pod 'React', :path => '../node_modules/react-native'
  pod 'react-native-fcm', :path => '../node_modules/react-native-fcm'

and looks like it solved the build problem, now have to check if it also works
EDIT:
@evollu Can you please look at this issue

I have the same issue, linking of React and Yoga in pods doesn't fix it.

@veedeo your solution worked for me

I had the same problem. I think there is problem with linking. In my case react-native link didn't link library properly. I removed pod 'react-native-fcm', :path => '../node_modules/react-native-fcm' and linked react-native-fcm manually and everything worked fine.

I ran npm install on my whole project again and link worked after that.

@veedeo are you able to create archive for ios with your solution.

Same here

@veedeo I had to do a bit more than that. I ended up with React in the pod and then that cause "ambiguous resolution" problems with react.

It is very similar to: https://github.com/invertase/react-native-firebase/issues/414

And then lots of cache clearing, swearing, and finally a reboot, it started to work. I can't say this is the right solution, and this feels really broken to me @evollu

  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native'
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

I'm not expert in pod configuration. seems what it does it build react and then remove it?
It is cleaner to do manual linking in my opinion

If you do the manual linking and try to use another google pod like 'GoogleSignIn' then you run into duplicate symbols. I didn't want to manually integrate both. The pod approach is cleaner (when it works!).

  1. When I use pod and got problem:
  2. Undefined is not an object when calling RNFIRMessaging.requestPermissions
  3. When I use manual link Firebase sdk and got problem:
    Undefined symbols for architecture x86_64:
  4. "_FIRLogBasic", referenced from:
    -[FIRMessagingLogger logFuncDebug:messageCode:msg:] in FirebaseMessaging(FIRMessagingLogger_790219f59b0990edc1544b20c012dab3.o)
    -[FIRMessagingLogger logFuncInfo:messageCode:msg:] in FirebaseMessaging(FIRMessagingLogger_790219f59b0990edc1544b20c012dab3.o)
    -[FIRMessagingLogger logFuncNotice:messageCode:msg:] in FirebaseMessaging(FIRMessagingLogger_790219f59b0990edc1544b20c012dab3.o)
    -[FIRMessagingLogger logFuncWarning:messageCode:msg:] in FirebaseMessaging(FIRMessagingLogger_790219f59b0990edc1544b20c012dab3.o)
    -[FIRMessagingLogger logFuncError:messageCode:msg:] in FirebaseMessaging(FIRMessagingLogger_790219f59b0990edc1544b20c012dab3.o)
    "_OBJC_CLASS_$_FIRApp", referenced from:
    objc-class-ref in AppDelegate.o
    objc-class-ref in FirebaseMessaging(FIRMessaging+FIRApp_990c986890993e9ee1072f08cac17bb3.o)

Notes: I reset all build and cache to test each option.
Versions:
react-native: 0.53.0
react-native-fcm :^13.3.1

Any solution?

@brunoczo Manual link react-native-fcm and Firebase lib from google solved my problem.

I update my project from rn v0.43 to 0.54 and now have this issue with rn fcm

I try to update react-native-fcm (16.0.0) to last v but it didnt fix it.

Any idea?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

holyxiaoxin picture holyxiaoxin  路  4Comments

404sand808s picture 404sand808s  路  5Comments

Keksike picture Keksike  路  5Comments

xavieramoros picture xavieramoros  路  4Comments

havinhthai picture havinhthai  路  4Comments