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.
There is documentation about this, but it is for macOs only. https://github.com/react-native-community/react-native-linear-gradient.
I linked the library by running npm install react-native link react-native-linear-gradient.
I don't understand this i dont have a ios folder, i installed pod but my ios folder remained empty:
iOS
For React Native >= 0.60.0 run the following command in the ios/ folder and skip the rest of the section.
pod install
CocoaPods
Add the following line to your Podfile:
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
or:
This below is only for macOs ?
Manually
Open your project in Xcode, right click on Libraries and click Add Files to "Your Project Name" Look under node_modules/react-native-linear-gradient/ios and add BVLinearGradient.xcodeproj. (Screenshot 1) (Screenshot 2).
Add libBVLinearGradient.a to Build Phases -> Link Binary With Libraries (Screenshot 1) (Screenshot 2).
Click on BVLinearGradient.xcodeproj in Libraries and go the Build Settings tab. Double click the text to the right of Header Search Paths and verify that it has $(SRCROOT)/../react-native/React - if it isn't, then add it. This is so Xcode is able to find the headers that the BVLinearGradient source files are referring to by pointing to the header files installed within the react-native node_modules directory. (Screenshot).
How to do it in Windows and i don't have an ios map inside node_modules/react-native-linear-gradient/?
how can i make it work?
Thanks for your time
use this one if you are using expo
1 . paste this in terminal window :
expo install expo-linear-gradient
2.add the import statement to the file :
import {LinearGradient} from 'expo-linear-gradient';
worked for me !
Check whether these two lines are in your 'package file'.
'React', :path => '../node_modules/react-native'
'BVLinearGradient', :path =>
'../node_modules/react-native-linear-gradient'
If yes then --
Run "pod install" under $project path/ios before react-native run-ios.
Cheers!!
Easy Way..! Try This..!
Run this code in Terminal window
expo install expo-linear-gradient
Use this code to import the LinearGradient
import { LinearGradient } from "expo-linear-gradient";
I had similar issue with Android.
Solution: Kill the app and relaunch this should solve the problem
First, install the https://github.com/react-native-community/react-native-linear-gradient library.
then go to the cd ios and run
cd ios
pod install
now use go back using cd ..
and run (optional )
react-native link react-native-linear-gradient
now run
react-native run-ios
Simply you just need to go to ios folder
cd ios
pod install
That's it
If using expo and this error is thrown after installing react-native-linear-gradient follow along.
error ? the expo framework still does not have "sight" of the linear gradient package .
solution ? Run the command "expo install expo-linear-gradient" from your root folder, go to the file that you had previously imported the linear gradient as "import LinearGradient from 'react-native-linear-gradient" and change the line to "import {LinerGradient} from 'expo-linear-gradient'".
Restart your server, "expo start".
PS: This solution is only applicable for react-native projects being built using expo
if you're using windows & react-native cli (not expo):
1- in android/settings.gradle, check if
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
exist .. if not, add them
2- in android/app/build.gradle, check if
implementation project(':react-native-linear-gradient')
exists in dependecies{ ... } .. if not, add it
3- in android/app/src/main/java/com/{YOUR_APP_NAME}/MainApplication.java , find
#Override
protected List getPackages() { ....}
Then replace the comment // packages.add(new MyReactNativePackage());
with =>
packages.add(new LinearGradientPackage());
Android
If you are on android, simply do the native rebuild again with:
yarn android
or
npm run android
I am using react-native 0.60.5
and after I added this module BlinkId via npm i blinkid-react-native then link it using react-native link blinkid-react-native
Now when I navigate to ios folder and run pod install I got this error
if I removed use_native_modules then pod install works fine but I got another error
null is not an object evaluating _RNGestureHandlerModule.default.Direction
any help with this?
I'm getting this error when calling Permissions.check() using the react-native-permissions library
I'm using the code straight from the react-native-permissions README
componentWillMount() {
Permissions.check('photo').then(response => {
console.log(response);
});
}
I used react-native link to link it.
react-native link react-native-permissions
I'm pretty sure it's linked correctly because when I call Permissions.getTypes()
componentWillMount() {
console.log(Permissions.getTypes());
}
I get the following response:
React Native Version: 0.53.0
React Native Permissions Version: 1.1.1
Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'myApp' do
pod 'Stripe', '~> 11.2.0'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
end
Edits
I downgraded React Native to 0.52.0 as that's the last react-native-permissions updated their README and I still get the same error.
It turns out,
Permissions.getTypes()
works without linking.
I ended up having to follow the manual linking instructions here: using manual linking
Using manual linking
In the XCode's "Project navigator", right click on your project's Libraries folder ➜ Add Files to <...>
Go to node_modules ➜ react-native-permissions ➜ select ReactNativePermissions.xcodeproj
Add libReactNativePermissions.a to Build Phases -> Link Binary With Libraries
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