运行 reset-project 脚本
了解如何使用 --local 标志在你的计算机或自定义基础架构上本地使用 EAS Build。
你可以使用 eas build --local 标志,在你的电脑上直接运行通常在 EAS Build 服务器上运行的相同构建过程。这是一种调试云端构建失败的有效方法,因为如果不运行相同的步骤,你可能无法重现这些问题。
🌐 You can run the same build process that is typically run on the EAS Build servers directly on your machine by using the eas build --local flag. This is a useful way to debug build failures that are happening on your cloud builds, which you may not be able to reproduce without running the same set of steps.
- eas build --platform android --local# or- eas build --platform ios --local先决条件
🌐 Prerequisites
你需要通过 Expo 的身份验证:
🌐 You need to be authenticated with Expo:
- 运行
eas login - 或者,使用基于令牌的身份验证设置
EXPO_TOKEN使用令牌认证
本地构建的用例
🌐 Use cases for local builds
- 调试 EAS 服务器上的构建失败。
- 公司政策限制使用第三方 CI/CD 服务。使用本地构建时,整个过程在你的基础设施上运行,并且与 EAS 服务器的唯一通信是:
- 确保项目
@account/slug存在 - 如果你使用托管凭据来下载它们
- 确保项目
使用本地构建进行调试
🌐 Use local builds for debugging
如果你在 EAS 服务器上遇到构建失败,并且无法通过检查日志确定原因,调试本地问题可能会有所帮助。为了简化这个过程,我们支持通过多个环境变量来配置本地构建过程。
🌐 If you encounter build failures on EAS servers and you're unable to determine the cause from inspecting the logs, you may find it helpful to debug the issue locally. To simplify that process we support several environment variables to configure the local build process.
EAS_LOCAL_BUILD_SKIP_CLEANUP=1- 设置此选项可在构建过程完成后禁用清理工作目录。EAS_LOCAL_BUILD_WORKINGDIR- 为构建过程指定工作目录,默认情况下它位于某个地方(取决于平台),通常在 /tmp 目录中。EAS_LOCAL_BUILD_ARTIFACTS_DIR- 构建成功后,工件被复制到的目录。默认情况下,这些文件会被复制到当前目录,如果你连续运行多个构建,这可能并不理想。
如果你在 iOS 构建中使用 EAS_LOCAL_BUILD_SKIP_CLEANUP 和 EAS_LOCAL_BUILD_WORKINGDIR,你应该能够检查工作目录中 logs 子目录的内容来读取你的 Xcode 日志。
🌐 If you use EAS_LOCAL_BUILD_SKIP_CLEANUP and EAS_LOCAL_BUILD_WORKINGDIR for iOS builds you should be able to inspect the contents of the logs subdirectory of the working directory to read your Xcode logs.
局限性
🌐 Limitations
某些云构建可用的选项在本地无法使用。你应注意的限制包括:
🌐 Some of the options available for cloud builds are not available locally. Limitations you should be aware of:
- 你只能为特定平台构建(选项
all已禁用)。 - 不支持自定义软件版本,eas.json 中的字段
node、yarn、fastlane、cocoapods、ndk、image将被忽略。 - 不支持缓存。
- 具有“Secret”可见性的 EAS 环境变量不被支持(请改为在本地环境中设置它们)。
- 你有责任确保环境安装了所有必要的工具:
- Node.js/Yarn/npm
- 快速通道(仅限 iOS)
- CocoaPods(仅限 iOS)
- Android SDK 和 NDK
- 在 Windows 上,你可以使用 WSL 进行本地 EAS 构建。然而,我们并未在此平台上进行官方测试,并且不支持在 Windows 上进行本地构建(支持 macOS 和 Linux)。
本地开发和生产构建的应用编译
🌐 App compilation for development and production builds locally
要在本地使用 Expo CLI 进行应用开发编译,请改用 npx expo run:android 或 npx expo run:ios 命令。如果你使用 Continuous Native Generation,你也可以运行 prebuild 来生成 android 和 ios 目录,然后在各自的 IDE 中打开项目并像任何原生项目一样进行构建。更多详情,请参见:
🌐 To compile your app locally for development with Expo CLI, use npx expo run:android or npx expo run:ios commands instead. If you use Continuous Native Generation, you can also run prebuild to generate your android and ios directories and then proceed to open the projects in the respective IDEs and build them like any native project. For more details, see:
学习如何在本地编译和构建你的 Expo 应用。
要在本地创建生产版本构建,你需要在电脑上安装 Android Studio 和 Xcode。更多信息请参见以下指南:
🌐 To create a production build locally, you need Android Studio and Xcode installed on your computer. See the following guide for more information:
了解如何在本地计算机上为你的 Expo 应用创建生产构建。
无论采用上述哪种方法,你都将遵循与使用 EAS Build 在云端创建构建不同的流程——这就是 eas build --local 标志的用途。
🌐 With any of the above approaches, you'll be following procedures which are different from creating a build on the cloud with EAS Build — that is what the eas build --local flag is for.