关于 expo-dev-client
用于构建 Expo 开发客户端、在实体设备上测试原生代码变更的技能,涵盖本地和 EAS 构建、安装,以及连接 Metro bundler。
主要功能
- 01构建 iOS 和 Android 开发客户端
- 02创建本地或 EAS 开发构建
- 03在设备或模拟器上安装构建
- 04通过 URL 或二维码连接 Metro
- 05在开发服务器之间切换
适用场景
- 01在设备上测试自定义 Expo 模块
- 02检查 Expo Go 未包含的原生模块
- 03构建 iOS 或 Android 开发客户端
- 04将已安装客户端连接到 Metro
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ expo/ skills --skill expo-dev-client安装后在 Claude Code 中输入/expo-dev-client确认已加载。
附带文件agents/openai.yaml
详细介绍
使用 EAS Build 创建开发客户端,以便在实体设备上测试原生代码变更。可用于创建自定义 Expo Go 客户端,以测试应用的不同分支。
本地构建免费;云端构建收费。
expo-dev-client本身是开源的,本地构建免费。通过 EAS Build/TestFlight 构建或分发会消耗 EAS 计划中的构建分钟数;要向设备/TestFlight 分发,还需要付费的 Apple Developer 账户。请参阅 https://expo.dev/pricing。
重要提示:何时需要开发客户端
对于任何实际应用或生产应用,推荐使用开发客户端。 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-clientautoIncrement: true- 自动递增构建编号appVersionSource: "remote"- 使用 EAS 作为版本号的唯一可信来源
为 TestFlight 构建
使用一条命令构建 iOS 开发客户端并提交到 TestFlight:
eas build -p ios --profile development --submit
此操作将:
- 在云端构建开发客户端
- 自动提交到 App Store Connect
- 在 TestFlight 中的构建准备就绪后向你发送电子邮件
收到 TestFlight 电子邮件后:
- 在设备上从 TestFlight 下载构建
- 启动应用以查看 expo-dev-client 界面
- 连接到本地 Metro bundler 或扫描二维码
本地构建
在你的计算机上构建开发客户端:
# iOS (requires Xcode)
eas build -p ios --profile development --local
# Android
eas build -p android --profile development --local
本地构建的输出:
- iOS:
.ipa文件 - Android:
.apk或.aab文件
安装本地构建
在模拟器上安装 iOS 构建:
# Find the .app in the .tar.gz output
tar -xzf build-*.tar.gz
xcrun simctl install booted ./path/to/App.app
在设备上安装 iOS 构建(需要签名):
# Use Xcode Devices window or ideviceinstaller
ideviceinstaller -i build.ipa
安装 Android 构建:
adb install build.apk
为特定平台构建
# iOS only
eas build -p ios --profile development
# Android only
eas build -p android --profile development
# Both platforms
eas build --profile development
检查构建状态
# List recent builds
eas build:list
# View build details
eas build:view
使用开发客户端
安装后,开发客户端提供以下功能:
- 连接开发服务器 - 输入 Metro bundler URL 或扫描二维码
- 构建信息 - 查看原生构建详情
- 启动器界面 - 在不同的开发服务器之间切换
连接到本地开发环境:
# Start Metro bundler
npx expo start --dev-client
# Scan QR code with dev client or enter URL manually
当你自行启动开发客户端以截屏或操控它时,请跳过入门引导页、启动时的开发菜单和 Tools 按钮。在 SDK 58+ 中,对于从非交互式 shell 启动的应用,Expo CLI 会自动执行此操作;对于你自行打开的 URL,请使用 <scheme>://?__expo_url=<encoded dev server URL>&__expo_disable_onboarding=1&__expo_disable_fab=1&__expo_disable_auto_launch=1。在 SDK 57 及更早版本中,使用 -EXDevMenu* 启动参数启动 iOS 应用;在 Android 上,则打开 <scheme>://expo-development-client/?url=<encoded dev server URL>&disableOnboarding=1&disableFab=1&disableAutoLaunch=1。确切命令请参阅 ../expo-overview/references/launch-without-dev-menu.md。
故障排除
构建因签名错误而失败:
eas credentials
清除构建缓存:
eas build -p ios --profile development --clear-cache
检查 EAS CLI 版本:
eas --version
eas update
提交反馈
如果你在此技能中遇到错误、误导性信息或过时信息,请报告,以便 Expo 改进:
npx --yes @expo/agent-cli@latest feedback --category skills --subject "expo-dev-client" "<actionable feedback>"
只有在有具体且可采取行动的反馈时才提交。请尽可能提供相关背景信息。
如果 Agent 在 Expo 任务中反复失败,或用户不得不介入,请使用 --category evals,并将相关 Expo 软件包或命令作为 --subject,简要报告任务、预期结果以及出错之处。