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

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)

Related

Uninstall package linked in cocoa pods for react native 0.63

I have an npm package I installed which I linked to cocoa pods via
npx pod install
I am looking to uninstall this pod as I have already uninstalled the npm package and am having trouble finding an article I am confident in trying since I am new to react-native and want to avoid crashing my app by making a mistake. Is there any easy process to complete this task?
EXTRA
xCode 12.4
React Native 0.63
When you do Pod install, it checks package.json and install pods for only those packages thats requires pod installation. RN v0.63 handles linking and unlinking itself, you don't need to worry about that, it has nothing to do with pod install command. Just do npm uninstall <package-name> and then re-run pod install to update pods as per package.json.

Could not find the following native modules after upgrading the react-native to latest version 0.61.4

After upgrading the react-native version I am getting the following. And failed to run the build in simulator
After this, I have run react-native run-ios it shows all my packages are manually linked and you need to unlink all packages.
Also, can anyone clarify the react-native-config.js file is mandatory for this after updating to the latest react-native.
Always I open the app.Xcodeproj but the below shows I need to open app.xcworkspace. Can anyone clarify this?
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- react-native-fetch-blob: https://github.com/wkh237/react-native-fetch-blob#readme
- react-native-orientation: https://github.com/yamill/react-native-orientation#readme
- rn-fetch-blob: https://github.com/joltup/rn-fetch-blob#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
error Could not find the following native modules: BugsnagReactNative, react-native-camera, react-native-cookies, react-native-fast-image, react-native-fetch-blob, RNFS, RNGestureHandler, RNImageCropPicker, react-native-image-picker, RNImageRotate, BVLinearGradient, react-native-orientation, RNShare, RNSVG, RNVectorIcons, RNViewShot, react-native-webview, rn-fetch-blob. Did you forget to run "pod install" ?
info Found Xcode workspace "Fashion.xcworkspace"
This should fix your issue.
rm -rf ios/Pods && rm -rf ios/build && cd ios && pod install && cd ../
rm -rf node_modules && rm yarn.lock && yarn install
PS: In react-native version 0.60 and above, native modules are now auto-linked. See the docs for more: https://facebook.github.io/react-native/blog/2019/07/03/version-60#native-modules-are-now-autolinked
firstly, when you update the react-native version, you should react-native official document. to avoid some wrong things. the details for update in the react-native update helper.
and for your question, since 0.60, CocoaPods are now part of React Native's iOS project. If you weren't already, be sure to open iOS platform code using the xcworkspace file from now on.
At the same time, a react-native link is now not needed in most situations anymore. the react-native team overhauled the linking process in general. Be sure to react-native unlink any preexisting dependencies as mentioned in the docs above.for more details, you can read this article.
for the rnpm problem, firstly you should delete it in the package.json.
then create a react-native.config.js file in project folder.
const ios = require('#react-native-community/cli-platform-ios');
const android = require('#react-native-community/cli-platform-android');
module.exports = {
project: {
ios: {},
android: {},
},
// assets: ['Resources/fonts'], // stays the same
// commands: require('./path-to-commands.js'),
};
then in the rn-fetch-blob(make is as an example), you also create
react-native.config.js and modify it according to its rnpm config
In the latest react-native stable version, you dont need to link the 3rd party libraries, just install it and it will work fine
Firstly,
So, when you are migrating from lower version to higher stable version,
then what you need to do, just unlink all the libraries you have used
in your project as react-native automatically detects its
dependencies. and moreover remember that whenever you install such
libaries you don't need to run the react-native link <library-name>
to link it.
Secondly,
Now you need to work with xcworkspace file as in the latest version,
ios are dealing with pods, and when pods comes into picture then you
have to use xcworkspace instead of Xcodeproj in your ios project
You can check the changelog here for react native 0.61.4 version.
I hope this helps....Thanks :)
My solution is to combine some tips above and update mine Pod file
Simply reset:
rm -rf ios/Pods && rm -rf ios/build
cd ios && pod install && cd ..
rm -rf node_modules && rm yarn.lock && yarn install
Reason is to maximize future compatibility.
Here is a facebook provided template, pick some goodies for your existing old pod file:
https://github.com/facebook/react-native/blob/0.63-stable/template/ios/Podfile
You may found code below is auto linking,
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
You may need to upgrade ios target
platform :ios, '10.0'
You may use Flipper without use_frameworks! enabled
Could be that there is something in your podfile that causes this. For example, I removed a library from my project but there was still a reference to it in the podfile:
pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
Once commenting/removing this line, pod install works great.
For me just converting npm install to yarn install worked because other team was using yarn and i was trying to install packages using npm so it created some conflict.
I recloned the project then
'yarn install', 'react-native link' and then
'pod install'

ios pod install returns "No podspec found for `FBSDKCoreKit"

I have a RN app which works on Windows. I pulled down the code to my Mac and I'm trying to run the code on my Mac. When I run pod install on my project's ios directory, the following error is output to the Terminal:
No podspec found for FBSDKCoreKit
Here is the full Terminal output:
My-MacBook-Pro:ios myname$ pod install Detected React Native module
pods for RNCAsyncStorage, RNFirebase, RNGestureHandler, RNReanimated,
RNVectorIcons, react-native-fbsdk, and react-native-safe-area-context
Analyzing dependencies Fetching podspec for DoubleConversion from
../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec
[!] No podspec found for FBSDKCoreKit in
../node_modules/react-native/Libraries/FBSDKCoreKit
What is the most likely root cause of this error and what troubleshooting steps would you recommend?
1) Make sure the path is there
../node_modules/react-native/Libraries/FBSDKCoreKit
2) Run a pod repo update and a pod install
If still not working I would try an unlink followed by a cleanup of any old links related to that library in project.pbxproj then link the library again.
Note: in some cases a pod deintegrate && pod install helped me with link errors like this.

How to fix 'boost/operators.hpp' file not found' error in react-native

when I use 'react-native run-ios', there is some error, 'boost/operators.hpp' file not found.
I can not build and run my project:
react-native-cli: 2.0.1
react-native: 0.59.9
npm: 6.9.0
yarn: 1.16.0
node: v12.4.0
os: macos 10.14.5
xcode: 10.2.1
▸ Compiling JSIDynamic.cpp
❌ /Users/lidongbo/WorkBentch/ReactNative/AwesomeProject/node_modules/react-native/React/../third-party/folly-2018.10.22.00/folly/dynamic.h:63:10: 'boost/operators.hpp' file not found
#include <boost/operators.hpp>
^
▸ Analyzing JSCRuntime.cpp
▸ Analyzing jsi.cpp
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening AwesomeProject.xcodeproj
project can build and run.
If you get this issue in react-native-reanimated after upgrading to react-native 0.66 update your react-native-reanimated in package.json
Try "react-native-reanimated": "2.3.0-beta.2"
Don't forget to run yarn install or npm install to update your packages. Also do a pod install for ios and restart your server instance .
EDIT:
Support for react-native#0.66 has been officially added by react-native-reanimated#2.2.3 It is less buggy and a lot more issues have been solved.
Also check issue on github.
This might due to incomplete pods install - try deleting ios/Pods folder and run pod install under ios.
An alternative error for the same issue that I encountered was:
ios/Pods/boost-for-react-native/boost/operators.hpp:97:10: 'boost/config.hpp' file not found
To fix it, you need to clear cocoa pods and cache and re-install.
Delete cocoa pods cache: rm -r ~/Library/Caches/CocoaPods
Delete the Pods folder and the Podfile.lock usually located in <project_root>/ios.
Reinstall pods: pod update
You must delete cache from wherever ios concerns; Here's the process I do to clear its cache:
Delete npm cache: npm cache clean --force
Delete All ios temp files: cd ios && rm -r Pods/ Podfile.lock {yourProject}.xcworkspace
Clear Cocoapods Cache: rm -r ~/Library/Caches/CocoaPods
now install pods via npx: cd .. && npx pod-install
So I was also getting the error boost/operators.hpp file not found but my issue was from using :path instead of :podspec in my Podfile. I'm working on an integrated RN app inside of a Native iOS app, so I was manually adding the pods to the Podfile (something I will not do from now on).
pod 'boost', :path => ...
instead of
pod 'boost', :podspec => ...
It might not be the most common fix but hoping it helps someone.
I resolve the problem.
boost_1_63_0.tar.gz
double-conversion-1.1.6.tar.gz
folly-2018.10.22.00.tar.gz
glog-0.3.5.tar.gz
These files are not completely downloaded due to network reasons.
The file url is :
{your proejct}/node_modules/react-native/scripts/ios-install-third-party.sh at lowest line.
When I upgraded RN 0.64 -> 0.66, the following helped me:
Delete cocoa pods cache: rm -r ~/Library/Caches/CocoaPods
Delete the Pods folder and the Podfile.lock usually located in <project_root>/ios
Delete Pod folder in <project_root>/ios
yarn add react-native-reanimated#2.2.3
pod install

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