非常教程

React native参考手册

指南(IOS) | Guides (iOS)

Linking Libraries

需要本机代码的项目

此页面仅适用于react-native init使用Create React Native App 制作的或使用此类应用程序弹出的项目。有关弹出的更多信息,请参阅创建React Native App存储库的指南。

并非所有应用程序都使用所有本机功能,并且包含支持所有这些功能的代码都会影响二进制大小......但我们仍然希望在需要时随时添加这些功能。

考虑到这一点,我们将这些功能中的很多作为独立的静态库进行了展示

对于大多数库文件来说,只需拖动两个文件就可以了,有时候需要进行第三步,但不能超过这个步骤。

我们随React Native一起提供的所有库都 位于存储库根目录中的文件夹中。其中一些是纯粹的JavaScript,你只需要它。其他库也依赖于一些本地代码,在这种情况下,您将不得不将这些文件添加到您的应用程序,否则应用程序会尝试使用该库时会引发错误。Libraries require

以下是链接包含本机代码的库的几个步骤

自动链接

Step 1

使用本地依赖项安装库:

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

注意: 或者标志对于这一步非常重要。反应原住民将基于链接的库,并在你的文件。--save --save-dev dependencies devDependencies package.json

Step 2

链接您的本地依赖项:

$ react-native link

完成!所有具有本机依赖性的库应该成功链接到您的iOS / Android项目。

手动链接

Step 1

如果库具有本机代码,则其.xcodeproj文件夹内必须有文件。将此文件拖放到Xcode上的项目中(通常在LibrariesXcode 的组下);

Linking Libraries

Step 2

单击您的主项目文件(代表该文件的文件.xcodeproj),Build Phases然后从Products您要导入的库内的文件夹中选择并拖动静态库Link Binary With Libraries

Linking Libraries

Step 3

不是每个图书馆都需要这一步,你需要考虑的是:

我需要在编译时了解库的内容吗?

这意味着什么,你是在本地使用这个库还是只使用JavaScript?如果你只是在JavaScript中使用它,那么你很好!

对于我们随React Native一起提供的库,除了PushNotificationIOS和之外,此步骤不是必需的Linking

在的情况下PushNotificationIOS,例如,你必须从你的呼吁库的方法AppDelegate收到一个新的推送通知每次。

为此,我们需要知道库的标题。为了实现这一点,你必须去你的项目文件,选择Build Settings并搜索Header Search Paths。在那里,你应该包括你的库的路径(如果它在子目录上有相关的文件记得做recursive,就像React例子中那样)。

Linking Libraries

React native

React Native 是一个 JavaScript 的框架,用来撰写实时的、可原生呈现 iOS 和 Android 的应用。

主页 https://facebook.github.io/react-native/
源码 https://github.com/facebook/react-native
发布版本 0.49

React native目录

1.开始 | Getting Started
2.指南 | Guides
3.APIs
4.组件:ActivityIndicator | Components: ActivityIndicator
5.组件:按钮 | Components: Button
6.组件:CheckBox | Components: CheckBox
7.组件:DatePickerIOS | Components: DatePickerIOS
8.组件:DrawerLayoutAndroid | Components: DrawerLayoutAndroid
9.组件:FlatList | Components: FlatList
10.组件:图像 | Components: Image
11.组件:KeyboardAvoidingView | Components: KeyboardAvoidingView
12.Components: ListView
13.Components: MaskedViewIOS
14.Components: Modal
15.Components: NavigatorIOS
16.Components: Picker
17.Components: PickerIOS
18.Components: ProgressBarAndroid
19.Components: ProgressViewIOS
20.Components: RefreshControl
21.Components: ScrollView
22.Components: SectionList
23.Components: SegmentedControlIOS
24.Components: Slider
25.Components: SnapshotViewIOS
26.Components: StatusBar
27.Components: Switch
28.Components: TabBarIOS
29.Components: TabBarIOS.Item
30.Components: Text
31.Components: TextInput
32.Components: ToolbarAndroid
33.Components: TouchableHighlight
34.Components: TouchableNativeFeedback
35.Components: TouchableOpacity
36.Components: TouchableWithoutFeedback
37.Components: View
38.Components: ViewPagerAndroid
39.Components: VirtualizedList
40.Components: WebView
41.创建 | Contributing
42.指南(Android) | Guides (Android)
43.指南(IOS) | Guides (iOS)
44.其他 | Miscellaneous