Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link library manually?

Tags:

react-native

I want to use react-native-youtube but it shows the error Native component for "RCTYouTube" does not exist, i try to find the solution it looks like i have to link the library manually if the library with native code.

But i have no idea with this link talk about Manual linking Step1 https://facebook.github.io/react-native/docs/linking-libraries-ios.html

I use type command create-react-native-app testyoutube to create my react native project, Visual Studio Code is my tool.

I'm not familiar with Xcode. I try to open my project folder testyoutube in Xcode. It will show an alert Could not open file.

If i want to follow Manual linking Step1 what step should i do ?

Here is my folder structure: enter image description here

Any help would be appreciated. Thanks in advance.

like image 946
Morton Avatar asked Dec 24 '22 07:12

Morton


2 Answers

To expand upon Adeel's answer:

  1. Locate the RCTYouTube.xcodeproj at {your project root} /node_modules/react-native-youtube.

  2. Use XCode to open your iOS project's .xcworkspace (or .xcodeproj if .xcworkspace does not exist).

  3. Locate the 'Libraries' folder in the project navigator pane on the left hand side of the window and drag the RCTVideo.xcodeproj file inside it.

  4. Select your project's target from the targets list pane on the inner left hand side of the window then scroll down to the 'Linked Libraries and Frameworks' section.

  5. Click the plus symbol at the bottom of the section and use the search bar to find 'libRTCYouTube.a', select it from the results, and hit the 'Add' button.

Your library should now be linked!

like image 125
ZardozSpeaks Avatar answered Dec 26 '22 00:12

ZardozSpeaks


You have two options to link libraries with your Xcode/Android project.

Automatic linking (run in your terminal in the root folder of your react-native project): react-native link

Manual Setup: It's actually very simple. Open your react native xcode project (.xcodeproject file) with Xcode.

On the left side you have the project navigator. Drag the Xcode project from react-native-youtube inside the Libraries group.

Project Navigator

enter image description here

Next step is to add the library to you project. Click on the left side on your xcode project in the project navigator. Go to the libraries section and add the RCTYoutube library.

After you have setup everything up, rebuild the project and you are good to go!

like image 29
PsykoSoldi3r Avatar answered Dec 25 '22 22:12

PsykoSoldi3r