Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md for installing react-native-unimodules when Adding Taro-React Native to an Existing Application #25

Open
wants to merge 1 commit into
base: 0.59.9
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Taro 原生 React Native 壳子,和 React Native init 的工程的区别是,

如已有原生项目,需自行集成,请参考 [react-native-unimodules](https://github.com/unimodules/react-native-unimodules) Readme。

如果`Taro`代码和原生项目代码的目录结构和`React-Native`官方文档建议的不同,则添加`react-native-unimodules`时请参考现有问题中该问题的做法。

## 现有问题

- 部分应用对包大敏感,觉得集成 [react-native-unimodules](https://github.com/unimodules/react-native-unimodules) 后包大小增加太多。
Expand All @@ -29,6 +31,21 @@ Taro 原生 React Native 壳子,和 React Native init 的工程的区别是,

参考:https://github.com/NervJS/taro/issues/3572

- 现有原生项目集成`react-native-unimodules`没成功

如果`Taro`代码和原生项目代码的目录结构和`React-Native`官方文档建议的不同,则添加`react-native-unimodules`并进行`pod install`时,会有以下提示:
```
"No unimodules found. Are you sure you've installed JS dependencies before installing pods?"
```
并且引入以下头文件不成功,因为模块没被成功导入。
```
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
```

此时需要传入`node_modules`路径,即修改`Podfile`文件中的`use_unimodules!()`为`use_unimodules!({modules_paths: ['./xxx/node_modules']})`

## 启动代码编译及 Metro Bundler Server

运行 `taro build` 命令,Taro 将会开始编译文件:
Expand Down