react-native-webview: Invariant Violation: requireNativeComponent: "RNCWKWebView" was not found in the UIManager
I am using react-native-cli
I installed react-native-webview with npm not yarn.
I linked react-native-webview by this following command:
react-native link react-native-webview
I got this message:
rnpm-install info Linking react-native-webview ios dependency rnpm-install info Platform 'ios' module react-native-webview has been successfully linked rnpm-install info Linking react-native-webview android dependency rnpm-install info Platform 'android' module react-native-webview has been successfully linked
Yet whenever I run “react-native run-ios” command, I got error RNCWKWebView not found in the UIManager.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 12
- Comments: 32 (1 by maintainers)
Maybe the link process is not being completed correctly for some reason on iOS. Have you tried to link manually?
Go to …/node_modules/react-native-webview/ios and drag and drop the RNCWebView.xcodeproj to Libraries folder on Xcode, right after, Go to Build Phases tab (on Xcode) in the section “Link binary With libraries” add the
libRNCWebView.a
(inside Libraries/RNCWebView.xcodeproj/Products). Try to build and runFor me the react-native link did not run “pod install” in the ios folder of the project. The main page in all practicality needs some info on this in troubleshooting part.
And a manual install section, preferably.
so a fix was to run “pod install” in the ios folder manually. If you don’t have pod installed and in your project already look for some guide about it. This should really be mentioned on the install instructions especially now that facebook is forwarding people to use this project.
(I used yarn for the install)
Same issue with android.
These are the changes that occured after the linking:
settings.gradle:
include ':react-native-webview' project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
build.gradle:
compile project(':react-native-webview')
MainApplication.java:
import com.reactnativecommunity.webview.RNCWebViewPackage;
Podfile:
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
This helped me from nvariant Violation: requireNativeComponent: “RNCWKWebView” was not found in the UIManager
We’re using RN .57 I’m seeing the same error as the original poster, following the standard process outlined in the install directions:
npm install react-native-webview@2.0.0 --save
react-native link
No reference in podfile - we’re not using this for all our ios dependencies. As a follow up, I’ve tried adding the reference to the podfile mentioned in the comment above, but that installs React, which conflicts with our existing react-native install and fails the build as well.
Additionally, I tried manually linking this as a dependency via dragging this project’s xcodeproj to my project’s libraries in XCode. The build succeeds but the component is not successfully linked for ios, and a redscreen renders as a result.
I don’t use pod install. What do I do?
exactly.
you need to add new RNCWebViewPackage() to mainApplication.java as said in the linked comment
Doing a manual pod install after linking the react-native-webview worked for me. i did run into this issue after running pod install though. resolved it with the top suggestion in the SO. https://stackoverflow.com/questions/50805753/duplicate-module-name-react-native
you probably did not add it inside the MainApplication.java
import com.reactnativecommunity.webview.RNCWebViewPackage;
and add new RNCWebViewPackage() to the packages list.
This often fail if you change MainApplication too much (using wix native navigation for example) this is other person answer
You need to check if react-native-webview/ios folder contain RNCWKWebView file or with other name? If other name then you need to use older version that has that file name inside ios folder. I believe this is a bug of react-native-webview. I also try to use v8.x, v7.x, there was error too… So I comeback with v5.12, that has RNCUIWebView in my case.
expo install react-native-webview
I can fix.
it doesn’t work
str:
react-native init AwesomeProject cd AwesomeProject
npm i --save react-native-navigation npm i --save react-native-webview
react-native link
then manual linking according to your advice
then react-native run-ios
Here is @Titozzz 's really great article:
https://engineering.brigad.co/demystifying-react-native-modules-linking-ae6c017a6b4a