React-native-firebase: can't build ios, React/RCTEventEmitter.h not found

Created on 9 Jan 2018  ·  33Comments  ·  Source: invertase/react-native-firebase

Issue

image

  • Podfile
 platform :ios, '9.0'
 use_frameworks!
 target "littlehome" do
   pod 'React', :path => '../node_modules/react-native', :subspecs => [
     'Core',
     'RCTText',
     'RCTImage',
     'RCTNetwork',
     'RCTSettings',
     'DevSupport',
     'RCTAnimation',
     'RCTWebSocket', # needed for localhost testing of your app
     'BatchedBridge',
     # Add any other subspecs you want to use in your project
   ]
   pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"


   pod 'RNSVG', :path => '../node_modules/react-native-svg'
   pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

   pod 'Firebase/Core'
   pod 'Firebase/DynamicLinks'
   pod 'Firebase/AdMob'

 end


 post_install do |installer|
   installer.pods_project.targets.each do |target|
     target.build_configurations.each do |config|
       config.build_settings['SWIFT_VERSION'] = '3.0'
     end
   end
 end

  • package.json

    "react-native": "^0.51.0",
    "react-native-firebase": "^3.2.0",

My project was initially non-react-native project, and react-native was added.

It works fine without react-native-firebase.
I succeeded making react-native-firebase work on android

I'm having trouble with ios.

As suggested in release notes and github issues, I added Firebase with pod,
I added react-native-firebase with react-native link .

It seems the RNFirebase.xcodeproj seems to fail to find <React/RCT....h> files.

I tried to adding various path to search header path with no success.
I tried adding or removing libRNFirebase.a , removing it resulted in successful build, but it showed RNFirebase core module was not found .. error when running.

react-native is installed with pod, and I think header files are copied somewhere and my top project is importing it fine.

I wonder which path to add to the RNFirebase project for the </React/..> headers.

I read every github issue relating this issue but can't figure out how to proceed..

It seems React headers are copied to

~/Library/Developer/Xcode/DerivedData/littlehome-bnihpopdwlkzxgavzfvevcjtxqpb/Build/Products/Debug-iphonesimulator/React/React.framework/Headers

How should I include it from RNFirebase project?

Environment

  1. Application Target Platform:
    ios
  2. Development Operating System:
    macOS sierra
  3. Build Tools:

  1. React Native version:
    0.51
  2. RNFirebase Version:
    3.2.1
  3. Firebase Module:
    core

Most helpful comment

@littlehome-eugene Did you also succeed with Archiving the project? We used the solution you guys came up with here and can build the projet fine (Debug or release) but when comes the time to archive it fails to find the header files again.

All 33 comments

@littlehome-eugene Are you able to try using the latest version on the 3.2.x branch and see if that fixes your issue?

npm install --save https://github.com/invertase/react-native-firebase#v3.2.x

If it does then I can do a release later today.

└── [email protected] (git+https://github.com/invertase/react-native-firebase.git#cfbef06776923c4785fcde709f6e52470990aa8b)

(i did npm install --save https://github.com/invertase/react-native-firebase#v3.2.x)

I removed RNFirebase.xproject from libraries folder and removed libRNFirebase.a from linked libraries and did link .
But as you can see, ios is not being linked?

$ react-native link react-native-firebase
Scanning folders for symlinks in /Users/eugenekim/Documents/zibann/momsite/app/node_modules (10ms)
rnpm-install info Android module react-native-firebase is already linked
You have new mail in /var/mail/eugenekim
eugenekim@eugenekimui-MacBook-Pro:~/Documents/zibann/momsite/app$

with [email protected]

$ react-native link react-native-firebase
Scanning folders for symlinks in /Users/eugenekim/Documents/zibann/momsite/app/node_modules (10ms)
rnpm-install info Android module react-native-firebase is already linked
rnpm-install info Linking react-native-firebase ios dependency
rnpm-install info iOS module react-native-firebase has been successfully linked
eugenekim@eugenekimui-MacBook-Pro:~/Documents/zibann/momsite/app$

nvm.. on second try, it is correctly linking.. weird.

I'm doing Alt-Cmd-k / Alt-Cmd-shift-k for cleaning and rebuilding... hope it goes well..

That's very odd. Once the library has been linked though, you won't need to re-link it, so having linked with 3.2.1, if you try running the install of the latest version, does this fix the missing RctEventEmitter errors?

So, now that it's linked, simply run:

npm install --save https://github.com/invertase/react-native-firebase#v3.2.x

And see if the app will now start up

ah I see, I removed libRNFirebase.a and re-linked but I don't see libRNFirebase.a under Link binary with Libraries

Is this ok?

I see compiling done well!

although I think without libRNFirebase.a I actually managed to build it fine previously..

And I see RNFirebase core module was not found error..

I'm trying with manually adding libRNFirebase.a now..

And with libRNFirebase.a added, I see the header file not found for React/RCTBridgeModule.h again..

In my limited knowledge, React headers are copied somewhere (although I can't see where because I don't have React.xcodeproj included under Libraries folder)

I believe it is ~/Library/Developer/Xcode/DerivedData/littlehome-bnihpopdwlkzxgavzfvevcjtxqpb/Build/Products/Debug-iphonesimulator/React/React.framework/Headers

I don't see a way of adding React/React.framework/Headers as React so that React/React.framework/Headers/RCTBridgeModule.h becomes React/RCTBridgeModule.h

Is it not the root cause of this problem?
Let me know if I can do anything else..

Ah, I've just noticed that you have use_frameworks! enabled which may be causing an issue.
Is there a reason you have this enabled?

I think it was because Alamorfire was using swift..

https://github.com/invertase/react-native-firebase/releases states 3.2.0 supports use_frameworks! .. ?

https://github.com/invertase/react-native-firebase/issues/252#issuecomment-352684878 . I'm having hard time to understand what @nagad814 I have just updated the release notes to make it clear that you should still use cocoapods for the Firebase SDK, but not for react-native-firebase itself means.. So use_frameworks! is still not supported?

I think the issue here is that whilst use_frameworks! does work in the simplest cases, it's failing here because React is being specified as a pod.

I need to try and build a simple, reproducible example that I can experiment with, which might take me a little while...

Aye,

I made a quick example using facebook's sample

https://github.com/littlehome-eugene/iOS-2048

Added use_frameworks!
added Firebase/core to pod
did react-native link
did npm install --save [email protected] react-native [email protected]

Thanks for the example. I've just cloned and had a play round and noticed that even without RNFirebase (I removed the linked library) this doesn't actually build with the use_frameworks flag enabled?

Ok... so having got it to compile without RNFirebase, I've figured out what's going on.

The issue is that XCode is parallelising the build, and building RNFirebase at the same time as the Pods which it depends on. As such, RNFirebase can't see the React headers as React hasn't finished building yet.

To fix it, can you try the following:

1) Edit the application scheme (Product > Scheme > Edit Scheme)
2) Make sure the application is selected at the top
3) Select the Build tab on the left
4) Uncheck Parallelize Build

Clean, and rebuild.

I'm still having the same error.

I unchecked the parallize build for both the top project and RNFirebase
I added react as a dependency to RNFirebase in the same Edit scheme - build

changed react version to 0.51 because of 0.52 type conversion bug of yoga.

I'm still seeing the header missing error on both my project and iOS-2048 project.

I commited the NumberTileGame.xcworkspace for you to see.

I had tested with xcode 8.3.3. and 9.2
I now have pod 1.4.0.rc.1 (because I saw somewhere use_framework is being worked on. I had trouble with 1.3.* as well)

Another thing I noticed is that it errors on Building target React not building target RNFirebase
(This seems to be due to the fact I added react as a dependency for RNFirebase in edit-scheme)

screen shot 2018-01-11 at 7 07 55 am

I see something is different with this toy example.

When I take out libRNFirebase.a , my project builds fine, but iOS-2048 doesn't..

I see iOS-2048 does compile without use_frameworks ..

So this sample project I made up is not a representative of what my project is having trouble with... it seems...

Isn't there be a chance that iOS-2048 not finding React header with use_frameworks! is due to the same cause of RNFirebase not finding React header though?

I can let you remote control my computer using teamviewer.. or ....

I tried to convert project so that react is not imported as pod.. (but it was tough too)

Do you think it might be easier to try that route?

Or I could live with some hack.. such as symlinking/copying header files to location where RNFirebase can see as React ...
Although I'm not sure how I could do that.....

Oh I made a project that exhibits the same symptom as mine off some other project..

this one has use_frameworks and builds fine without libRNFirebase.a, and fails to build with it.
Parallelize is also turned off..

https://github.com/littlehome-eugene/swift-react-native-hybrid

You're right, for some reason turning off parallelization makes no difference on this project.
I'm afraid I'm at a bit of a loss as to what to suggest now.

Ok, attempt number 3214...

1) Update to RNFirebase v3.2.2
2) Re-enable parallelize build if you've disabled it
3) Select the RNFirebase.xcodeproj library in the Xcode navigator
4) Select the Build Phases tab
5) Under Link Binary With Libraries, add the Pods_{projectName}.framework file

This seems to ensure that the Pods are built before RNFirebase.

Let me know if this works...

@chrisbianca

It Works!

Thank you very much for the support!

NONONO.. I cleaned and rebuilt and it fails again..

let me try few more times..

It seems it works with parallerize turned off but not with turned on

Yes, only with paralleize turned off, it works. It works, It works!

@littlehome-eugene I'm glad it finally works!! I'll add some additional notes to the setup instructions. Thanks for your help debugging.

Thank you again!! Glad I could help.

@littlehome-eugene Did you also succeed with Archiving the project? We used the solution you guys came up with here and can build the projet fine (Debug or release) but when comes the time to archive it fails to find the header files again.

@Jack-Rouleau, I just attempted an archive and I'm also seeing that failure. Have you had any luck on figuring out a solution?

@chrisbianca I'm working on a shared project with react-native-firebase and the other two developers aren't seeing this issue at all. I'm the only one having this problem, even after pulling down a fresh copy of the repo so everything is identical to the other devs. Do you have any thoughts as to why this is still happening?

Also, all of us are having the issue with this error popping up when attempting to archive. It seems like this issue should be re-opened.

We're on react-native-firebase version 3.3.1.

Thanks!

@cdunkel We've made some further changes to the headers in v4 (releasing later today) that will hopefully resolve these sorts of issues. However, given the fragmented state of the RN ecosystem, it's very difficult to ensure we've caught every possible scenario.

The fact that you have multiple developers on the same code base who see different behaviour is concerning, and highlights that there may be differences in how your build environment is set up. Different version of xcode, cocoapods, etc...

@chrisbianca I'm excited to try v4 and see if that solves any of our issues! I agree that seeing different behavior on the different platforms is concerning, and I'm ever more concerned that I can't archive. One of the developers for whom it _was_ working is now seeing the same issues I was, so that's interesting too. I've also been going through and trying to make sure that everyone is on the same versions of things. So far I think everyone is consistent.

I'm new to RN and definitely seeing what you mean about the fragmentation...

@cdunkel sorry for the late reply, yes we had problems with archiving and had to tweak few other things to make it work.

and we had to try different things everytime we do 'pod install'
We did something like adding library to search path, but it's a mess and we don't have a definite answer. Hope v4 solves the problem.. We haven't tried it

I have the same issue - Build & Run work fine, Archive fails with "React/RCTBridgeModule.h" file not found.

package.json:
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-firebase": "^4.3.7",

Disabled parallelized build, added FirebaseCore and React to the build scheme. Still no joy.

Any ideas please?

Thanks

[EDIT] I fixed the issue using the workaround described in this post (Copy the RNFirebase source into the project rather than the RNFirebase project): https://github.com/invertase/react-native-firebase/issues/1061#issuecomment-393795692

react-native 0.56.0 , I can't archive again..

It's not just react-native-firebase, other libraries seem to have the same problem.

@littlehome-eugene we don't support rn 0.56 yet, see https://github.com/invertase/react-native-firebase/issues/1283 - will be supported in v5 of React Native Firebase.

I'd like to share how I'm solving the header problem.

I see similar problems with other RN libraries other than RNFirebase.

I know it is weird but I believe xcode has a bug where it can't recognize the setting we set through build settings for the Framework search path and build phases for the Link Binary with Libraries .

When archiving fails, I do the following,

remove $(built_products_dir) and add it back along with $(built_products_dir)/include
remove Pods_{project_name}.framework and add back in.

Normally it works. I know it sounds weird, but same setting might not persist when you archive next time, I do the above to resolve it.

Adding the Pods_{project_name}.framework to the RNFirebase project is only a local change that will not be checked in to the repo because it exists in the node_modules folder which should be ignored. I have also added both the Pods_{project_name}.framework and RNFirebase to the scheme build settings but it still doesn't force the build to build the Pods first. I think this might be because of RNFirebase scheme has parallelize build turned on

Adding the Pods_{project_name}.framework to the RNFirebase project is only a local change that will not be checked in to the repo because it exists in the node_modules folder which should be ignored. I have also added both the Pods_{project_name}.framework and RNFirebase to the scheme build settings but it still doesn't force the build to build the Pods first. I think this might be because of RNFirebase scheme has parallelize build turned on

Hey, facing the same issue , I dont have a framework with 'Pods_(my_project_name)'

I am facing the above issue after installing React native firebase. Tried most of the above solutions. Can anyone help?
Mentioned my pods file below

`target 'project_name' do
Uncomment the next line if you're using Swift or would like to use dynamic frameworks

pod 'FBSDKLoginKit'
pod 'Firebase/Core', '~> 5.20.1'
pod 'Firebase/Messaging', '~> 5.20.1'
pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'

pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

pod 'RNGoogleSignin', :path => '../node_modules/react-native-google-signin'

pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

pod 'ReactNativeNavigation', :path => '../node_modules/react-native-navigation'

pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

pod 'GoogleSignIn', '~> 4.4.0'

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

end
end`

Was this page helpful?
0 / 5 - 0 ratings