SuperAPI AI 工具集

expo-dev-client-v55

编程与开发

查看项目

更新于 10-27 16:20

技能介绍

用途

expo-dev-client 用于构建和分发 Expo 开发客户端(development client),以便在物理设备上测试原生代码改动,或为应用的测试分支创建自定义 Expo Go 客户端。开发客户端是任何真实或生产应用的推荐配置;Expo Go 是用于学习和快速实验的游乐场,只包含其内置的原生库,大多数应用会超出它的范围并转向开发客户端。

何时需要开发客户端

仅在以下情况需要开发客户端:

  • 使用本地 Expo 模块(自定义原生代码)
  • 使用 Apple 目标(小组件、App Clip、扩展)
  • 使用 Expo Go 中不包含的第三方原生模块
  • 使用配置插件,或测试远程推送通知与 App/Universal Links

EAS 配置

确保 eas.json 中包含 development 配置:

{
  "cli": {
    "version": ">= 16.0.1",
    "appVersionSource": "remote"
  },
  "build": {
    "production": {
      "autoIncrement": true
    },
    "development": {
      "autoIncrement": true,
      "developmentClient": true
    }
  },
  "submit": {
    "production": {},
    "development": {}
  }
}

关键设置:

  • developmentClient: true:为开发构建打包 expo-dev-client
  • autoIncrement: true:自动递增构建号
  • appVersionSource: "remote":以 EAS 作为版本号的唯一来源

为 TestFlight 构建

用一条命令构建 iOS 开发客户端并提交至 TestFlight:

eas build -p ios --profile development --submit

该命令会:

  • 在云端构建开发客户端
  • 自动提交至 App Store Connect
  • 当构建在 TestFlight 中就绪时向你发送邮件

收到 TestFlight 邮件后:

  • 在设备上从 TestFlight 下载构建
  • 启动应用以查看 expo-dev-client UI
  • 连接到本地 Metro 打包器或扫描二维码

本地构建

在本机构建开发客户端:

# iOS(需要 Xcode)
eas build -p ios --profile development --local

# Android
eas build -p android --profile development --local

本地构建输出:

  • iOS:.ipa 文件
  • Android:.apk 或 .aab 文件

安装本地构建

在模拟器上安装 iOS 构建:

# 在 .tar.gz 输出中找到 .app
tar -xzf build-*.tar.gz
xcrun simctl install booted ./path/to/App.app

在设备上安装 iOS 构建(需要签名):

# 使用 Xcode Devices 窗口或 ideviceinstaller
ideviceinstaller -i build.ipa

安装 Android 构建:

adb install build.apk

为特定平台构建

# 仅 iOS
eas build -p ios --profile development

# 仅 Android
eas build -p android --profile development

# 两个平台
eas build --profile development

检查构建状态

# 列出最近的构建
eas build:list

# 查看构建详情
eas build:view

使用开发客户端

安装后,开发客户端提供:

  • 开发服务器连接:输入 Metro 打包器 URL 或扫描二维码
  • 构建信息:查看原生构建详情
  • 启动器 UI:在多个开发服务器之间切换

连接到本地开发:

# 启动 Metro 打包器
npx expo start --dev-client

# 用开发客户端扫描二维码或手动输入 URL

故障排查

构建因签名错误失败:

eas credentials

清除构建缓存:

eas build -p ios --profile development --clear-cache

检查 EAS CLI 版本:

eas --version
eas update

提交反馈

如果遇到错误,或发现本技能中存在误导性或过时信息,可向 Expo 报告以便改进:

npx --yes submit-expo-feedback@latest --category skills --subject "expo-dev-client" "<actionable feedback>"

仅在有具体且可操作的反馈时提交,并尽可能包含相关上下文。如果 AI 代理反复失败,或用户不得不接管某个 Expo 任务,请加载 expo-skill-feedback 技能并遵循其 eval-candidate 流程,而不是重复使用上述命令。

费用与限制

本地构建免费;云端构建为付费。expo-dev-client 本身是开源软件,本地构建免费。通过 EAS Build/TestFlight 构建或分发会消耗 EAS 套餐的构建分钟数,且设备/TestFlight 分发需要付费的 Apple Developer 账号。详见 https://expo.dev/pricing。