Merge pull request #300 from tadeuzagallo/doc-link-libraries
[ReactNative][Docs] Document how to link libraries
This commit is contained in:
commit
d83cd3ea65
|
@ -0,0 +1,67 @@
|
||||||
|
---
|
||||||
|
id: libraries
|
||||||
|
title: Linking Libraries
|
||||||
|
layout: docs
|
||||||
|
category: Guides
|
||||||
|
permalink: docs/linking-libraries.html
|
||||||
|
next: debugging
|
||||||
|
---
|
||||||
|
|
||||||
|
Not every app uses all the native capabilities, and including the code to support
|
||||||
|
all those features would impact in the binary size... But we still want to make
|
||||||
|
easy to add these features whenever you need them.
|
||||||
|
|
||||||
|
With that in mind we exposed many of these features as independent static libraries.
|
||||||
|
|
||||||
|
For most of the libs it will be as simples as dragging two files, sometimes a third
|
||||||
|
step will be necessary, but no more than that.
|
||||||
|
|
||||||
|
_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 just 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._
|
||||||
|
|
||||||
|
## Here the few steps to link your libraries that contain native code
|
||||||
|
|
||||||
|
### Step 1
|
||||||
|
|
||||||
|
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 `Libaries` group
|
||||||
|
on Xcode);
|
||||||
|
|
||||||
|
![](/react-native/img/AddToLibraries.png)
|
||||||
|
|
||||||
|
### Step 2
|
||||||
|
|
||||||
|
Click on your main project file (the one that represents the `.xcodeproj`)
|
||||||
|
select `Build Phases` and drag the static library from the `Products` folder
|
||||||
|
insed the Library you are importing to `Link Binary With Libraries`
|
||||||
|
|
||||||
|
![](/react-native/img/AddToBuildPhases.png)
|
||||||
|
|
||||||
|
### Step 3
|
||||||
|
|
||||||
|
Not every library will need this step, what you need to consider is:
|
||||||
|
|
||||||
|
_Do I need to know the contents of the library at compile time?_
|
||||||
|
|
||||||
|
What that means is, are you using this library on the native site or just in
|
||||||
|
JavaScript? If you are just using it in JavaScript, you are good to go!
|
||||||
|
|
||||||
|
|
||||||
|
This step is not necessary for all libraries that we ship we React Native but
|
||||||
|
`PushNotificationIOS` and `LinkingIOS`.
|
||||||
|
|
||||||
|
In the case of the `PushNotificationIOS` for example, you have to call a method
|
||||||
|
on the library from your `AppDelegate` every time a new push notifiation is
|
||||||
|
received.
|
||||||
|
|
||||||
|
For that 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 you library (if it has relevant
|
||||||
|
files on subdirectories remember to make it `recursive`, like `React` on the
|
||||||
|
example).
|
||||||
|
|
||||||
|
![](/react-native/img/AddToSearchPaths.png)
|
|
@ -4,7 +4,7 @@ title: Native Modules (iOS)
|
||||||
layout: docs
|
layout: docs
|
||||||
category: Guides
|
category: Guides
|
||||||
permalink: docs/nativemodulesios.html
|
permalink: docs/nativemodulesios.html
|
||||||
next: debugging
|
next: libraries
|
||||||
---
|
---
|
||||||
|
|
||||||
Sometimes an app needs access to platform API, and React Native doesn't have a corresponding wrapper yet. Maybe you want to reuse some existing Objective-C or C++ code without having to reimplement it in JavaScript. Or write some high performance, multi-threaded code such as image processing, network stack, database or rendering.
|
Sometimes an app needs access to platform API, and React Native doesn't have a corresponding wrapper yet. Maybe you want to reuse some existing Objective-C or C++ code without having to reimplement it in JavaScript. Or write some high performance, multi-threaded code such as image processing, network stack, database or rendering.
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 598 KiB |
Binary file not shown.
After Width: | Height: | Size: 820 KiB |
Binary file not shown.
After Width: | Height: | Size: 568 KiB |
Loading…
Reference in New Issue