109 行
2.0 KiB
Markdown
109 行
2.0 KiB
Markdown
|
|
# React Native 安装配置
|
|||
|
|
|
|||
|
|
**包名**:`@xuqm/rn-sdk` · **版本**:0.2.x · **RN 版本**:≥ 0.76.0
|
|||
|
|
|
|||
|
|
> `rn-sdk` 作为内部基础包存在,业务方正常接入时使用 `@xuqm/rn-common` 和各业务模块即可。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## npm / yarn 安装
|
|||
|
|
|
|||
|
|
在项目根目录创建 `.npmrc`:
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
@xuqm:registry=https://nexus.xuqinmin.com/repository/npm-hosted/
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
只使用基础能力时,直接安装 `rn-common`:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
yarn add @xuqm/rn-common
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
按需安装模块时,`rn-im` / `rn-push` / `rn-update` 都会自动带上 `rn-common` 和 `rn-sdk`:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
yarn add @xuqm/rn-common @xuqm/rn-im
|
|||
|
|
# 或全量安装
|
|||
|
|
yarn add @xuqm/rn-common @xuqm/rn-im @xuqm/rn-push @xuqm/rn-update
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 自动 / 手动链接
|
|||
|
|
|
|||
|
|
React Native 0.60+ 支持**自动链接**,安装后执行:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd ios && pod install
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
> 若使用 Expo,需先执行 `expo prebuild` 生成原生项目后再执行 `pod install`。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## iOS 配置
|
|||
|
|
|
|||
|
|
### Pod 安装
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd ios
|
|||
|
|
pod install
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 权限声明
|
|||
|
|
|
|||
|
|
在 `Info.plist` 中添加:
|
|||
|
|
|
|||
|
|
```xml
|
|||
|
|
<key>NSCameraUsageDescription</key>
|
|||
|
|
<string>需要访问相机</string>
|
|||
|
|
<key>NSPhotoLibraryUsageDescription</key>
|
|||
|
|
<string>需要访问相册</string>
|
|||
|
|
<key>NSMicrophoneUsageDescription</key>
|
|||
|
|
<string>需要访问麦克风</string>
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Android 配置
|
|||
|
|
|
|||
|
|
### Gradle 仓库
|
|||
|
|
|
|||
|
|
在 `android/build.gradle` 中确保包含:
|
|||
|
|
|
|||
|
|
```gradle
|
|||
|
|
allprojects {
|
|||
|
|
repositories {
|
|||
|
|
maven { url "https://nexus.xuqinmin.com/repository/android/" }
|
|||
|
|
google()
|
|||
|
|
mavenCentral()
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 最低版本
|
|||
|
|
|
|||
|
|
- `minSdkVersion = 24`
|
|||
|
|
- `compileSdkVersion = 34`
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 依赖关系
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
@xuqm/rn-sdk(meta-package,不建议业务方直接引用)
|
|||
|
|
├── @xuqm/rn-common ← 初始化、网络、设备信息
|
|||
|
|
├── @xuqm/rn-im ← IM 模块(依赖 WatermelonDB)
|
|||
|
|
├── @xuqm/rn-push ← Push 模块
|
|||
|
|
└── @xuqm/rn-update ← 更新模块
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 下一步
|
|||
|
|
|
|||
|
|
- [RN IM 接入 →](./im)
|
|||
|
|
- [RN 群聊 →](./group)
|
|||
|
|
- [RN 版本更新 →](./update)
|