React Native ~ Linking Libraries - rohit120582sharma/Documentation GitHub Wiki

Introduction

All the libraries we ship with React Native live on the Libraries folder in the root of the repository. Some of them are pure JavaScript, and you only need to require it. Other libraries also rely on some native code, in that case you'll have to add these files to your app, otherwise the app will throw an error as soon as you try to use the library.

Libraries



Automatic linking

Install a library with native dependencies:

npm install <library-with-native-dependencies> --save

Link your native dependencies:

react-native link <library-with-native-dependencies>

Done! Library with native dependencies should be successfully linked to your iOS/Android project.



Manual linking for iOS

If the library has native code, there must be a .xcodeproj file inside it's folder. Drag this file to your project on Xcode (usually under the Libraries group on Xcode);


Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag the static library from theProducts folder inside theLibrary you are importing to Link Binary With Libraries


If you do need to call it from native, then we need to know the library's headers. To achieve that you have to go to your project's file, select Build Settings and search for Header Search Paths. There you should include the path to your library. (This documentation used to recommend using recursive, but this is no longer recommended, as it can cause subtle build failures, especially with CocoaPods.)

⚠️ **GitHub.com Fallback** ⚠️