435 lines
9.0 KiB
Markdown
435 lines
9.0 KiB
Markdown
# EAS 云构建指南
|
||
|
||
> 适用于 TriloopTem App (TEM Receiver)
|
||
> 最后更新:2026-06-20
|
||
|
||
本文档详细说明如何使用 Expo EAS 云构建服务编译 Android APK 和 iOS IPA,包括所有账号注册和配置步骤。
|
||
|
||
---
|
||
|
||
## 一、前置准备
|
||
|
||
### 1.1 所需账号
|
||
|
||
| 账号 | 用途 | 费用 |
|
||
|------|------|------|
|
||
| Expo 账号 | EAS 云构建平台 | 免费(30 次/月构建额度) |
|
||
| Google 开发者账号 | 上架 Google Play(可选) | $25 一次性 |
|
||
| Apple Developer Program | iOS 签名和分发(必须) | ¥688/年 |
|
||
|
||
### 1.2 本地环境
|
||
|
||
```
|
||
Node.js >= 18
|
||
npm >= 9
|
||
Git(代码需在 Git 仓库中)
|
||
```
|
||
|
||
---
|
||
|
||
## 二、注册 Expo 账号
|
||
|
||
1. 访问 https://expo.dev/signup
|
||
2. 填写用户名、邮箱、密码,完成注册
|
||
3. 验证邮箱
|
||
|
||
---
|
||
|
||
## 三、注册 Apple Developer Program(iOS 必须)
|
||
|
||
### 3.1 注册 Apple ID
|
||
|
||
如果没有 Apple ID:
|
||
1. 访问 https://appleid.apple.com/account
|
||
2. 填写姓名、邮箱、手机号
|
||
3. 完成双重认证设置
|
||
|
||
### 3.2 加入 Apple Developer Program
|
||
|
||
1. 访问 https://developer.apple.com/programs/enroll/
|
||
2. 点击「开始注册」
|
||
3. 选择注册类型:
|
||
- **个人** — 适合个人开发者,只需 Apple ID
|
||
- **组织** — 需要 DUNS 编号(邓白氏编码),适合公司
|
||
4. 填写个人/公司信息
|
||
5. 支付年费 **¥688**(支持 Visa/MasterCard/银联)
|
||
6. 等待审核(通常 24-48 小时)
|
||
|
||
### 3.3 审核通过后
|
||
|
||
- 登录 https://developer.apple.com 确认会员状态为 Active
|
||
- 记住你的 **Team ID**(在 Membership 页面可以看到)
|
||
|
||
---
|
||
|
||
## 四、安装和配置 EAS CLI
|
||
|
||
### 4.1 安装
|
||
|
||
```bash
|
||
npm install -g eas-cli
|
||
```
|
||
|
||
### 4.2 登录 Expo 账号
|
||
|
||
```bash
|
||
eas login
|
||
```
|
||
|
||
输入注册的 Expo 用户名和密码。
|
||
|
||
### 4.3 验证登录
|
||
|
||
```bash
|
||
eas whoami
|
||
```
|
||
|
||
显示你的用户名即为成功。
|
||
|
||
---
|
||
|
||
## 五、项目配置
|
||
|
||
### 5.1 确认 app.json
|
||
|
||
确保 `app.json` 中以下字段已正确填写:
|
||
|
||
```json
|
||
{
|
||
"expo": {
|
||
"name": "TEM Receiver",
|
||
"slug": "TriloopTem_App",
|
||
"version": "1.0.0",
|
||
"ios": {
|
||
"bundleIdentifier": "com.triloop.temreceiver"
|
||
},
|
||
"android": {
|
||
"package": "com.triloop.temreceiver"
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
### 5.2 初始化 EAS 配置
|
||
|
||
```bash
|
||
cd f:\1_Projects\2026\SixChannelApp\TriloopTem_App
|
||
eas build:configure
|
||
```
|
||
|
||
自动生成 `eas.json` 文件。手动编辑为以下内容:
|
||
|
||
```json
|
||
{
|
||
"cli": {
|
||
"version": ">= 5.0.0"
|
||
},
|
||
"build": {
|
||
"development": {
|
||
"developmentClient": true,
|
||
"distribution": "internal",
|
||
"android": {
|
||
"buildType": "apk"
|
||
},
|
||
"ios": {
|
||
"simulator": true
|
||
}
|
||
},
|
||
"preview": {
|
||
"distribution": "internal",
|
||
"android": {
|
||
"buildType": "apk"
|
||
}
|
||
},
|
||
"production": {
|
||
"android": {
|
||
"buildType": "apk"
|
||
}
|
||
}
|
||
},
|
||
"submit": {
|
||
"production": {
|
||
"ios": {
|
||
"appleId": "你的Apple ID邮箱",
|
||
"ascAppId": "App Store Connect中的App ID(上架时填写)"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
### 5.3 确保代码在 Git 仓库中
|
||
|
||
EAS 需要 Git 仓库:
|
||
|
||
```bash
|
||
git add -A
|
||
git commit -m "准备 EAS 构建"
|
||
```
|
||
|
||
---
|
||
|
||
## 六、构建 Android
|
||
|
||
### 6.1 Preview 版(内部测试用 APK)
|
||
|
||
```bash
|
||
eas build --platform android --profile preview
|
||
```
|
||
|
||
首次构建会提示:
|
||
- **Generate a new Android Keystore?** → 选 **Yes**(EAS 自动管理签名密钥)
|
||
|
||
构建过程(约 10-20 分钟):
|
||
1. 代码上传到 EAS 云端
|
||
2. 云端安装依赖
|
||
3. 编译生成 APK
|
||
4. 提供下载链接
|
||
|
||
### 6.2 Production 版(正式发布用)
|
||
|
||
```bash
|
||
eas build --platform android --profile production
|
||
```
|
||
|
||
### 6.3 下载 APK
|
||
|
||
构建完成后终端会显示下载链接,也可以在 https://expo.dev 的项目页面查看。
|
||
|
||
```bash
|
||
# 查看构建列表
|
||
eas build:list --platform android
|
||
```
|
||
|
||
---
|
||
|
||
## 七、构建 iOS
|
||
|
||
### 7.1 首次构建
|
||
|
||
```bash
|
||
eas build --platform ios --profile production
|
||
```
|
||
|
||
首次构建会依次提示以下内容:
|
||
|
||
#### 第 1 步:Apple 账号登录
|
||
|
||
```
|
||
? Do you want to log in to your Apple account? › Yes
|
||
|
||
? Apple ID: › 输入你的 Apple ID 邮箱
|
||
? Password: › 输入密码
|
||
```
|
||
|
||
如果开启了双重认证,会要求输入 6 位验证码。
|
||
|
||
#### 第 2 步:选择开发者团队
|
||
|
||
```
|
||
? Select Team ›
|
||
❯ XXXXXXXX - 你的名字/公司名 (Team ID)
|
||
```
|
||
|
||
选择你的开发者团队。
|
||
|
||
#### 第 3 步:Bundle Identifier 确认
|
||
|
||
```
|
||
? Bundle Identifier: › com.triloop.temreceiver
|
||
```
|
||
|
||
直接回车使用默认值。
|
||
|
||
#### 第 4 步:签名证书管理
|
||
|
||
```
|
||
? How would you like to manage your credentials? ›
|
||
❯ Let Expo handle it (Recommended)
|
||
I want to provide my own
|
||
```
|
||
|
||
**选择 "Let Expo handle it"**。EAS 会自动:
|
||
- 创建 Distribution Certificate(发布证书)
|
||
- 创建 Provisioning Profile(配置文件)
|
||
- 安全存储在 EAS 服务器上
|
||
|
||
#### 第 5 步:等待构建
|
||
|
||
iOS 构建约 15-30 分钟。进度可在终端或 https://expo.dev 查看。
|
||
|
||
### 7.2 后续构建
|
||
|
||
第二次及以后的构建不再需要上述交互,直接运行:
|
||
|
||
```bash
|
||
eas build --platform ios --profile production
|
||
```
|
||
|
||
### 7.3 下载 IPA
|
||
|
||
```bash
|
||
eas build:list --platform ios
|
||
```
|
||
|
||
或访问 https://expo.dev 项目页面下载。
|
||
|
||
---
|
||
|
||
## 八、安装到设备
|
||
|
||
### 8.1 Android
|
||
|
||
下载 APK 后直接安装:
|
||
|
||
```bash
|
||
adb install app-xxx.apk
|
||
```
|
||
|
||
或将 APK 发送到手机上点击安装。
|
||
|
||
### 8.2 iOS — 内部测试(Ad Hoc)
|
||
|
||
**注意**:需要先注册测试设备的 UDID。
|
||
|
||
#### 注册测试设备
|
||
|
||
1. 手机 Safari 访问 https://expo.dev/register-device
|
||
2. 安装描述文件获取 UDID
|
||
3. 在 EAS 中注册设备:
|
||
|
||
```bash
|
||
eas device:create
|
||
```
|
||
|
||
按提示输入设备 UDID 和名称。
|
||
|
||
#### 构建 Ad Hoc 版本
|
||
|
||
```bash
|
||
eas build --platform ios --profile preview
|
||
```
|
||
|
||
构建完成后生成安装链接,在手机 Safari 中打开即可安装。
|
||
|
||
### 8.3 iOS — TestFlight 分发
|
||
|
||
适合分发给多人测试:
|
||
|
||
#### 提交到 App Store Connect
|
||
|
||
```bash
|
||
eas submit --platform ios
|
||
```
|
||
|
||
提示:
|
||
```
|
||
? Select a build to submit › 选择最近的构建
|
||
? Apple ID: › 你的 Apple ID
|
||
```
|
||
|
||
提交后:
|
||
1. 登录 https://appstoreconnect.apple.com
|
||
2. 进入「我的 App」→ 选择 App → TestFlight
|
||
3. 等待 Apple 审核(通常几分钟到几小时)
|
||
4. 审核通过后添加内部/外部测试人员
|
||
5. 测试人员在 TestFlight App 中安装
|
||
|
||
---
|
||
|
||
## 九、上架应用商店(可选)
|
||
|
||
### 9.1 Google Play
|
||
|
||
1. 注册 Google Play 开发者账号($25 一次性):https://play.google.com/console/signup
|
||
2. 在 Google Play Console 创建应用
|
||
3. 构建 AAB 格式:
|
||
|
||
修改 `eas.json` 的 production profile:
|
||
```json
|
||
"production": {
|
||
"android": {
|
||
"buildType": "app-bundle"
|
||
}
|
||
}
|
||
```
|
||
|
||
```bash
|
||
eas build --platform android --profile production
|
||
eas submit --platform android
|
||
```
|
||
|
||
### 9.2 App Store
|
||
|
||
1. 在 App Store Connect 创建 App:https://appstoreconnect.apple.com
|
||
2. 填写 App 信息(名称、描述、截图、分类等)
|
||
3. 提交构建:
|
||
|
||
```bash
|
||
eas build --platform ios --profile production
|
||
eas submit --platform ios
|
||
```
|
||
|
||
4. 在 App Store Connect 中选择构建版本
|
||
5. 提交审核(通常 24-48 小时)
|
||
|
||
---
|
||
|
||
## 十、常用命令速查
|
||
|
||
```bash
|
||
# ── 账号 ──
|
||
eas login # 登录
|
||
eas whoami # 查看当前账号
|
||
|
||
# ── 构建 ──
|
||
eas build -p android # 构建 Android(默认 production)
|
||
eas build -p ios # 构建 iOS
|
||
eas build -p all # 同时构建双平台
|
||
eas build -p android --profile preview # 指定 profile
|
||
eas build:list # 查看构建历史
|
||
eas build:cancel # 取消当前构建
|
||
|
||
# ── 设备管理(iOS Ad Hoc)──
|
||
eas device:create # 注册测试设备
|
||
eas device:list # 查看已注册设备
|
||
|
||
# ── 提交商店 ──
|
||
eas submit -p android # 提交到 Google Play
|
||
eas submit -p ios # 提交到 App Store
|
||
|
||
# ── 证书管理 ──
|
||
eas credentials # 管理签名证书
|
||
```
|
||
|
||
---
|
||
|
||
## 十一、常见问题
|
||
|
||
### Q: 构建失败,提示 "Missing credentials"
|
||
**A:** 运行 `eas credentials` 重新配置签名证书。
|
||
|
||
### Q: iOS 构建提示 "No bundle identifier"
|
||
**A:** 确认 `app.json` 中 `ios.bundleIdentifier` 已填写。
|
||
|
||
### Q: 免费额度用完了怎么办
|
||
**A:** 等下个月刷新(每月 30 次),或改用本地构建(Android 用 `build-release.bat`,iOS 需要 Mac)。
|
||
|
||
### Q: 不想用 EAS 管理证书,可以自己管理吗
|
||
**A:** 可以。首次构建时选 "I want to provide my own",然后上传你的 .p12 证书和 .mobileprovision 文件。
|
||
|
||
### Q: Android 签名密钥丢了怎么办
|
||
**A:** EAS 自动管理的密钥存储在 Expo 服务器,不会丢失。可以用 `eas credentials` 随时下载备份。
|
||
|
||
---
|
||
|
||
## 十二、费用总结
|
||
|
||
| 场景 | 费用 |
|
||
|------|------|
|
||
| 仅构建 Android APK | **免费**(EAS 免费额度) |
|
||
| 构建 iOS + 自己测试 | **¥688/年**(Apple Developer) |
|
||
| 上架 Google Play | **$25 一次性** + 免费构建 |
|
||
| 上架 App Store | **¥688/年**(Apple Developer) |
|
||
| 双平台上架 | **¥688/年 + $25** |
|