提示信息
# 同伴 App — SDK 接入总览与 Podfile 配置
> 本文档汇总所有第三方 SDK 的 CocoaPods 依赖、初始化时序与 Info.plist 配置要求。
---
## 一、Podfile 依赖清单
| SDK | Pod 名称 | 版本 | 用途 |
|-----|----------|------|------|
| OpenIM | `OpenIMSDK-iOS` | `~> 3.8` | 即时通讯(单聊、会话、消息) |
| 微信 | `WechatOpenSDK-XCFramework` | `~> 2.0` | 登录 / 分享 / 支付 |
| 支付宝 | `AlipaySDK_No_UTDID` | 最新 | App 支付(No_UTDID 避免与阿里云冲突) |
| 安全检测 | `IOSSecuritySuite` | 最新 | 越狱 / 调试 / 逆向 / 完整性检测 |
| 阿里云反馈 | `AlicloudFeedback` | `~> 3.3` | 用户反馈(EMAS 平台) |
### 1.1 CocoaPods 源配置
```ruby
source 'https://github.com/CocoaPods/Specs.git' # 官方仓库
source 'https://github.com/aliyun/aliyun-specs.git' # 阿里云私有仓库
```
> `AlicloudFeedback` 托管在阿里云私有 Specs 仓库,必须添加第二个 source。
### 1.2 为什么用 `AlipaySDK_No_UTDID`
阿里云 SDK(AlicloudFeedback)内置 UTDID 组件。如果同时使用标准 `AlipaySDK-iOS`,会出现 UTDID 符号重复冲突。使用 `AlipaySDK_No_UTDID` 可规避此问题。
---
## 二、初始化时序(隐私合规)
```
App 启动
│
├── 1. UIKit 初始化(AppDelegate / SceneDelegate)
│
├── 2. 检查隐私协议同意状态
│ ├── 未同意 → 展示隐私协议弹窗
│ └── 已同意 → 进入 SDK 初始化
│
└── 3. PrivacyService.initSDKs()(用户同意后)
├── a. IOSSecuritySuite 安全检测(最先执行)
├── b. OpenIM SDK 初始化
├── c. 微信 SDK 注册
├── d. 阿里云反馈 SDK 初始化
└── e. 支付宝无需提前初始化(调用时初始化)
```
> **合规关键**:所有采集类 SDK 必须在用户同意隐私协议**之后**才能初始化。
---
## 三、Info.plist 配置
### 3.1 URL Schemes(CFBundleURLTypes)
```xml
<key>CFBundleURLTypes</key>
<array>
<!-- 微信回调 -->
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>wx146a6f748a99a0da</string>
</array>
<key>CFBundleURLName</key>
<string>weixin</string>
</dict>
<!-- 支付宝回调 -->
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>tongban</string>
</array>
<key>CFBundleURLName</key>
<string>alipay</string>
</dict>
</array>
```
### 3.2 LSApplicationQueriesSchemes(白名单)
```xml
<key>LSApplicationQueriesSchemes</key>
<array>
<!-- 微信 -->
<string>weixin</string>
<string>wechat</string>
<string>weixinULAPI</string>
<!-- 支付宝 -->
<string>alipay</string>
<string>alipays</string>
<!-- IOSSecuritySuite 越狱检测 -->
<string>undecimus</string>
<string>sileo</string>
<string>zbra</string>
<string>filza</string>
<string>cydia</string>
</array>
```
### 3.3 Universal Links(Associated Domains)
在 Xcode → Signing & Capabilities → Associated Domains 添加:
```
applinks:www.tongban.wang
```
### 3.4 权限声明(Usage Descriptions)
| 权限键 | 中文描述 |
|--------|----------|
| `NSCameraUsageDescription` | 需要访问您的相机以拍摄照片或视频 |
| `NSLocationWhenInUseUsageDescription` | 为了给您推荐附近的用户和信号,需要获取您的位置信息 |
| `NSMicrophoneUsageDescription` | 需要访问麦克风以录制语音信号 |
| `NSMotionUsageDescription` | 此权限将用于优化广告投放体验 |
| `NSPhotoLibraryUsageDescription` | 需要访问相册以发布图片信号 |
| `NSUserTrackingUsageDescription` | 该标识符将用于向您投放个性化广告 |
---
## 四、各 SDK 配置参数速查
### OpenIM
| 参数 | 值 |
|------|-----|
| API 地址 | `https://im-api.tongban.wang` |
| WS 地址 | `wss://im-ws.tongban.wang/msg_gateway` |
| 平台 ID | `5`(iOS) |
| UID 前缀 | `tb_` |
| DB 目录 | `Documents/im_db/` |
### 微信
| 参数 | 值 |
|------|-----|
| App ID | `wx146a6f748a99a0da` |
| Universal Link | `https://www.tongban.wang/app/` |
### 支付宝
| 参数 | 值 |
|------|-----|
| URL Scheme | `tongban` |
### 阿里云 EMAS
| 参数 | 值 |
|------|-----|
| App Key (iOS) | `335670805` |
| App Secret (iOS) | `7e54b6689c624b37a3d90b99756397bf` |
| APM RSA Secret | `MIGfMA0GCSqGSIb3DQEBA...(见完整配置)` |
---
## 五、pod install 操作步骤
```bash
# 1. 添加阿里云 CocoaPods 仓库(首次)
pod repo add AliyunRepo https://github.com/aliyun/aliyun-specs.git
# 2. 安装依赖
cd /path/to/同伴
pod install
# 3. 后续更新
pod repo update AliyunRepo
pod update
```
安装完成后,始终使用 `同伴.xcworkspace` 打开项目。
---
## 六、详细接入文档索引
| 文档 | 说明 |
|------|------|
| [swift_SDK安全检测_IOSSecuritySuite.md](swift_SDK安全检测_IOSSecuritySuite.md) | 21 个 API、8 大检测类别完整说明 |
| [swift_SDK微信与支付宝.md](swift_SDK微信与支付宝.md) | 微信登录/支付 + 支付宝支付接入 |
| [swift_SDK阿里云_反馈与APM.md](swift_SDK阿里云_反馈与APM.md) | AlicloudFeedback 初始化与使用 |
| [swift_IM适配器与推送.md](swift_IM适配器与推送.md) | OpenIM SDK + APNs 推送(已有) |