'event2/event-config.h' file not found - react-native

I am trying to build a react-native app in iOS but unfortunately coming across the following issue (referring to libevent/Flipper):
'event2/event-config.h' file not found
I have react-native v0.63.4 and I have linked the packages using react-native link and also run pod update. I have also deleted my Podfile.lock and run pod install again.
My guess is that it is something to do with the Flipper version? When I comment out use_flipper! in my Podfile and build, it works.
Any ideas on how I can resolve this?

Facebook released an update yesterday for flipper with v74 and added support for arm64 devices.
so Flipper v74 should have a fix for arm64 devices
Setup:
Using the latest Flipper SDK#
By default React Native might ship with an outdated Flipper SDK. To make sure you are using the latest version, determine the latest released version of Flipper by running npm info flipper.
Android:
Bump the FLIPPER_VERSION variable in android/gradle.properties, for example: FLIPPER_VERSION=0.74.0. Run ./gradlew clean in the android directory.
iOS:
Call use_flipper with a specific version in iOS/Podfile, for example: use_flipper!({ 'Flipper' => '0.74.0' }).
Run pod install in the ios directory.
we can see how to setup flipper for react-native here: https://fbflipper.com/docs/getting-started/react-native
This link Solved my issue..Update of pods after changing Flipper Version..refer this
with this version I fixed the 'event2/event-config.h' file not found issue.
Update
Xcode version is now 12.5 and needs a new Flipper version to be installed.
Flipper v95 is now released.
here how to add it:
use_flipper!({ 'Flipper' => '0.95.0' })

I bumped into the same issue after updating to Xcode 12.4 and updating MacOS. The issue comes from files in flipper-folly.
How to fix it
1. If you don't need flipper
If you are not using flipper in your app, just open your Podfile in your ios app project folder and comment out these lines of code.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
2. If you need to use flipper in your app.
If you still need to use flipper in your app then specify the flipper-folly version as follows
use_flipper!({ 'Flipper-Folly' => '2.3.0' }) # update this part
post_install do |installer|
flipper_post_install(installer)
end
NOTE:
You will need to update your pods by running
pod update
or
pod install
Also remember to update your cocoapods
sudo gem install cocoapods
Refer to this issue for more information.

A common mistake was use_flipper instead of add_flipper_pods
In Podfile I Found every one is using
use_flipper!({ 'Flipper-Folly' => '2.3.0' })
But I use
add_flipper_pods!('Flipper' => '0.74.0')
then run
pod install
solved for me

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'client' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'clientTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
# use_flipper!
use_flipper!({ 'Flipper' => '0.80.0' })
post_install do |installer|
flipper_post_install(installer)
end
end
target 'client-tvOS' do
# Pods for client-tvOS
target 'client-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Just change use_flipper! to use_flipper!({ 'Flipper' => '0.80.0' })
Then either in ios folder, run pod install again, or in your react native project root directory, run npx pod-install again.

Not sure exactly where this crept in, but I had the same problem. I did a macos xcode update last night. I also frequently update the project dependencies, so either of those might have triggered this.
In anycase, it appears that the Podfile.lock somehow switched from CocoaLibEvent to libevent 2, which seems to be the issue with 'event2/event-config.h' file not found
I deleted Podfile.lock and ./Pods/ Then did a pod repo update, and pod update and now its working again.

2 steps to solve the issue:
add the following line in iOS/PodFile via xcode
use_flipper!({ 'Flipper' => '0.74.0' })
run pod install in terminal inside project's iOS directory
now try to build, it would be successful

If you have
add_flipper_pods
In your Podfile then replace that line by below code
add_flipper_pods!({ 'Flipper' => '0.87.0', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1' })
If you have
use_flipper
In your Podfile then replace that line by below code
use_flipper!({ 'Flipper' => '0.87.0', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1' })

I have Update macOS and Xcode after that I have got this problem. this seems that Flipper 2.5.1 has some problem. u can simply rid out of it by simple the following code into your profile
Here are some screenshots that may help you.
after this update your pod with the command
pod update
and also
sudo gem install cocoapods.

This seems to have something to do with pod update vs pod install. I've always used pod update without much problem:
pod update:
Downloading dependencies
Installing Flipper-Folly 2.5.1 (was 2.3.0)
Installing Flipper-RSocket 1.3.0 (was 1.1.0)
Installing OpenSSL-Universal 1.1.180 (was 1.0.2.20)
Installing libevent (2.1.12) <<<<<<<<<<<<<<
Removing CocoaLibEvent <<<<<<<<<<<<<
Generating Pods project
Integrating client project
pod install:
Analyzing dependencies
Downloading dependencies
Installing CocoaLibEvent (1.0.0) <<<<<<<<<<<<
Installing Flipper-Folly 2.3.0 (was 2.5.1)
Installing Flipper-RSocket 1.1.0 (was 1.3.0)
Installing OpenSSL-Universal 1.0.2.20 (was 1.1.180)
Removing libevent <<<<<<<<<<<
Generating Pods project
Integrating client project
I'm definitely out of my element here....

The IOs project is not detecting the flipper library so you need to update the version and update the podfile.
1)-Bump the FLIPPER_VERSION variable in android/gradle.properties, for example: FLIPPER_VERSION=0.75.0.
Run ./gradlew clean in the android directory.
iOS:
Call use_flipper with a specific version in ios/Podfile, for example: use_flipper!({ 'Flipper' => '0.75.0' }).
2)- then run "pod repo update" or "pod install --repo-update" in IOs folder instead of "pod install" if the latter does not work.

It might sound a bit weird but for people using M1 chip based laptop might get resolve their issue by following the steps:
1 - With Xcode closed (Important) Go to finder -> Applications
2 - Right Click on Xcode and select "Get Info"
3 - On the info panel check "Open using Rosetta"
4 - Double Click in the bottom large preview of the info panel.
5 - Actions to install Rosetta will be responsive.
After following these steps, When I build the app in xcode it ran fine. Also, there was a issue that my simulator was not loading the changes of react native, that also got resolved by performing these steps.
Adding reference of the issues after this podfile related issue is resolved. There are chances that you might get this error.
For details you can go to this question. Link

Using the latest Flipper SDK#
By default React Native might ship with an outdated Flipper SDK. To make sure you are using the latest version, determine the latest released version of Flipper by running npm info flipper.
Android:
Bump the FLIPPER_VERSION variable in android/gradle.properties, for example: FLIPPER_VERSION=0.79.1.
Run ./gradlew clean in the android directory.
iOS:
Call use_flipper with a specific version in ios/Podfile, for example: use_flipper!({ 'Flipper' => '0.79.1' }).
Run pod install in the ios directory.

use_flipper!({ 'Flipper-Folly' => '2.3.0', 'Flipper-RSocket' => '1.1' })

Upvote #spanky's answer.
The only thing I may add to this is that if removing Podfile.lock and Pods/ doesn't work, then you may have to go into the Podfile.lock and replace every libevent & libevent(2.x.x) occurrence with CocoaLibEvent & CocoaLibEvent(). Then you will want to delete the Pod/ directory and run:
pod deintegrate
pod install

Just add
arch -x86_64 before your start command for M1 Macs.
I spent lots of time finding a solution and finally above worked for me.

This worked for me,
Considering the fact that react native 0.62 and above comes with flipper inbuilt, you can remove all the flipper dependencies in your Podfile.
After I removed all of it, it gave no errors while building.

Related

React Native 0.63 generated podfile [!] The Podfile does not contain any dependencies

I have built an app which is working on android fine. I have now got a MacBook Pro (M1) and am trying to build my RN app to iOS.
I ran sudo gem install cocoapods
I installed the packages at the root using npm install
cd ios
pod init
here is my podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'caffeind' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for caffeind
target 'caffeindTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'caffeind-tvOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for caffeind-tvOS
target 'caffeind-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
as you can see there are no pods where I expected more, so when I run pod install i receive the message and rightly so...
Pod installation complete! There are 0 dependencies from the Podfile and 0 total pods installed.
[!] The Podfile does not contain any dependencies.
however when I then go to build in my Xcode using caffeind.xcworkspace file, I receive the error
'React/RCTBridgeDelegate.h' file not found
there is some helpful advice here - https://github.com/facebook/react-native/issues/25838 but...
I cannot add React to the schemes and I do not see it in my Libraries folder in my project navigator. As the above error seems to be linked to the cocoapods dependency, I believe these issues are linked and whenever I try to manually add React pods to the podfiles there is always another dependency or pod that it needs.
This is my xCode directory
caffeind
caffeind
Libraries - empty
Products
Frameworks
Resources
Pods
pods
-etc
versions:
React Native - 0.63.2
React Native cli - 4.14.0
Ruby - 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
Cocoapods - 1.10.1
Xcode - 12.4
MacBook Pro - Big Sur - 11.2.3 - M1

Xcode builds successfully a corrupted archive, not showing in organizer, as soon as cocoapods installs react-native-mapbox-gl from Podfile

The problem seems not new, as here, but the solutions proposed didn't work.
I tried also several other approaches to understand what's going on (see here).
To replicate, this is the process:
I have a working iOS App written in Swift.
I follow the description to integrate this app with Native React this procedure
I add to the package.json the following dependencies, and run yarn install:
"#react-native-mapbox-gl/maps":"^8.1.0-rc.9",
"prop-types": "^15.6.2",
I run pod install --repo-update and Archive on Xcode.
OUTPUT: At this point the organizer displays my Archive.
I implement a basic view on mapbox following this procedure
I add to the Podfile requiring use_framework!, as described here or after use_framework!, no difference in the result after I hit pod install --repo-update.
I hit Archive on Xcode.
OUTPUT: the archive is generated successfully, but doesn't show up on the organizer. If I try to open it, the archive is corrupted.
If I remove the pod file of mapbox and I Archive the project after hitting pod install --repo-update, the archive works and shows up in the organizer. Here the same description.
The project runs both as debug and release on a real iPhone 8. Mapbox works well. However, it doesn't work on simulator, nor archive. I can leave with the former, but I can't push on App store because of the latter.
I would not give up as Mapbox is very nice and provides lots of features. What could it be?
SOLUTION :
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.9.3
rm Podfile.lock
rm -rf Pods
pod install
LAST MESSAGES :
Same here. Impossible to find any solution.
Xcode is building a incomplete archive file. (By incomplete, I mean that in the archive package, some files are missing, like info.plist)
If this can help, I'm using MapboxGL too.
Edit :
Found this https://github.com/react-native-mapbox-gl/maps/issues/1097#issuecomment-725689831
Edit 2:
This link was the solution !
I got the exact same problem with :
#react-native-mapbox-gl/maps": "8.1.0"
COCOAPODS: 1.10.1
Xcode 12.4
The archive was corrupted (missing parts like the plist)
The trick for me was to remove the copy dsym build phase of the #react-native-mapbox-gl-mapbox-static pod
This phase was causing build failure with some config and malformed archive with others, I don't really get the crux of the problem but may be it can help some of you...
It looks like mapbox issue. I had the same issue and instead of downgrading the cocoapods I used this solution:
Edit your package.json, set:
"#react-native-mapbox-gl/maps": "^8.2.0-beta1",
2. Run yarn install or npm install.
3. Put the code into your ios/Podfile between pre_install do |installer| and end:
$RNMBGL.pre_install(installer)
And between post_install do |installer| and end:
$RNMBGL.post_install(installer)
Run cd ios && pod install
After these steps I was able to generate to archive.

React Native - pod install issue "cannot load such file.......node_modules/react-native/scripts/react_native_pods"

when I have a react native project....and when I run pod install it gives me the following error
Invalid `Podfile` file: cannot load such file -- /myPath/node_modules/react-native/scripts/react_native_pods
Here is my podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'xs' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'xsTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'xs-tvOS' do
# Pods for xs-tvOS
target 'xs-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Ive checked and there is no file called react_native_pods in location myPath/node_modules/react-native/scripts/.
Im wondering if its something to do with npm install is not generating correct files.....however I upgraded node to most recent version and then ran npm install
I ran npm audit fix and it added react_native_pods file and pod install then worked
Run npm audit fix ==> cd ios ==> pod install
If npm audit fix is not working for you then try below solution.
- sudo gem install cocoapods
- npm i
- cd ios
- pod install
It can also be that you just forgot to run yarn / npm before running pod install.
I have meet the same error, solved by upgrade the version of React Native from 0.62 to 0.63, it works for me
Because of the file react_native_pods does't exists in the folder scripts when the version is 0.62, It appears when I upgraded the version of RN to 0.63, after npm install , It works when pod install, hope it would help other who encounter the same error
I just did npm install before running pod install and it solved for me.
In my case Ive deleted yarn.lock, podfile.lock and it worked fine after yarn and pod install again
in order to fix this: what i did is:
react-native upgrade: It mainly upgrades react-native version, which will also upgrade some of your ios files such as Podfile amongst other things.
Try if this works for you or not. You can also create a latest react native project and compare your files/directories using "Beyond compare", also you need to rename some lines in your files.
Also read the comments in files for better understanding.
This wroked for me:
cd ios
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
Via this link.
I had this error in 2022 and this was the most relevant search result and didn't fix it.. so in case anyone else out there is running into this, I fought this for days and finally fixed it by:
Creating a brand new directory by: expo init new-project and then copy over your .js files, screens, and assets etc. Do this by hand, don't copy any of your lock files or node-modules or anything else. Just the files that you created/touched yourself. Then expo start. Load the project on your mobile / simulator and when it fails with a module requirement missing add it individually. Repeat this start-error-add until the build succeeds. This was the only way I found to get it working.
Make sure you've installed your npm dependencies.
Run following command and then install pods.
To install npm packages:
yarn install
And then, remove old pod cache:
cd ios && pod deintegrate && rm -rf Podfile.lock
To update pods and start ios:
pod install --repo-update && cd .. && react-native run-ios
Yarn
cd ios
pod install
Works for me
just install,
#react-native-community/cli-platform-ios
in package.json
then yarn install in your root and cd ios and also arch -x86_64 pod install
verify that you have a node_modules folder, I was missing that
Go and add react-native.pods.rb file inside of Node_Module->React-Native->Scripts->(add here)

React Native and pod installation failure

I'm trying to install the libary ( pusher ) onto IOS that is made with react-native language.
The command I used was
pod 'libPusher', git: 'https://github.com/pusher/libPusher.git', branch: 'push-notifications
The error that I got was
[!] Unknown command: `libPusher,`
Did you mean: list?
Usage:
$ pod COMMAND
CocoaPods, the Cocoa library package manager.
...
I have no idea why this pod installation doesn't work. Pod version is 1.0.1.
(pod --version)
Please share any idea with me!
Not sure if you ever figured this out, but the line Pusher gives you isn't for the command line. Add it to your Podfile:
target 'MyApp' do
pod 'libPusher', git: 'https://github.com/pusher/libPusher.git', branch: 'push-notifications'
end
Then run pod install to install it
Try adding -lc++ to your Tests Other Linker Flags

React Native fbsdk in iOS

When I added fbsdk in my project, I got errors like -
Warning: Native component for "RCTFBLikeView" does not exist
2016-06-21 22:27:38.898 [warn][tid:com.facebook.react.JavaScript]
Warning: Native component for "RCTFBLoginButton" does not exist
2016-06-21 22:27:38.899 [warn][tid:com.facebook.react.JavaScript]
Warning: Native component for "RCTFBSendButton" does not exist
2016-06-21 22:27:38.900 [warn][tid:com.facebook.react.JavaScript]
Warning: Native component for "RCTFBShareButton" does not exist
To solve this I went through this pod method -
https://github.com/facebook/react-native-fbsdk/issues/126
Now, when I run pod install command, I am getting this error -
No podspec found for react-native-fbsdkcore in
../node_modules/react-native-fbsdk/iOS/RCTFBSDK/core".
Can anybody tall what is wrong here ?
This is my pod file -
platform :ios, ‘7.0’
use_frameworks!
xcodeproj ‘/Users/ais/Netizen/ios/Netizen.xcodeproj’
target ’Netizen’ do
source ‘https://github.com/CocoaPods/Specs.git’
pod 'React', :subspecs => ['Core', 'RCTImage', 'RCTNetwork', 'RCTText', 'RCTWebSocket'], :path => '/Users/ais/Netizen/node_modules/react-native'
pod 'react-native-fbsdkcore', :path => ‘../node_modules/react-native- fbsdk/iOS/RCTFBSDK/core’
pod 'react-native-fbsdklogin', :path => '../node_modules/react-native-fbsdk/iOS/RCTFBSDK/login’
pod 'react-native-fbsdkshare', :path => '../node_modules/react-native-fbsdk/iOS/RCTFBSDK/share’
end
target ‘NetizenTests' do
end
I was struggling with this recently and what I found to work is that, after running react-native install react-native-fbsdk you still need to run react-native link react-native-fbsdk.
The libRCTFBSDK.a will then appear under Link Binary with Libraries in Xcode but (I think) needs to be removed and then re-added by clicking the - and + buttons at the bottom.
Pod spec support has been removed since a recent version. It expects the FacebookSDK to be ~/Documents directory. See issue here https://github.com/facebook/react-native-fbsdk/issues/181
I have installed react-native-fbsdk and link using react-native-link react-native-fbsdk.
Follow instruction of following link
https://developers.facebook.com/docs/react-native/configure-ios
This provide to link react-native library using ios_setup.js
There are following step which i have followed.
Setup on facebook developer account .
Install the file ios_setup.js by executing the following command in a command prompt at your project's root folder.
curl -O https://raw.githubusercontent.com/facebook/react-native-fbsdk/master/bin/ios_setup.js
Install the plist package, the xcode package, and the adm-zip package, by executing the following command.
npm install plist xcode adm-zip
Run the script ios_setup.js by executing the following command, and insert your app's App ID and App Name. If the name of your app is more than one word long, then enclose it between quotation marks.
node ios_setup.js [App ID] [App Name]
When run node ios_setup.js it wll automatically link all files in ios.