This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

为 iOS 设备创建并运行云构建

编辑页面

了解如何使用 EAS Build 为 iOS 设备配置开发构建。


In this chapter, we will create a development build that can run on iOS devices using EAS Build.

Development builds for iOS devices are generated in the .ipa format, which is the standard format for installing iOS apps.

Watch: Create a development build for a physical iOS device
Watch: Create a development build for a physical iOS device

Learn how to build and run a development build on a physical iOS device using EAS Build, including setting up code signing.


Prerequisites

2 requirements

1.

Apple Developer account

Access to the required credentials used to sign our app is needed, because each build requires signing to verify that the app comes from a trusted source. EAS Build can help manage these credentials.

2.

Enable Developer Mode on iOS 16 and later

Developer Mode must be enabled to install development builds on a device. If this is your first time using it, or if it is currently disabled, see Enable Developer Mode.

配置文件

要在 iOS 设备上开始开发,我们需要:

  • 通过创建新的 配置文件 来注册设备。
  • 将此配置文件下载并安装到设备上。

1

注册 iOS 设备

使用 EAS CLI,运行命令来注册新的 Apple 设备:

Terminal
eas device:create

此命令会提示我们回答以下问题:

  • 你位于项目目录中。是否要使用 your-account-name 账户?Y
  • Apple ID. 在这一步中,输入你的 Apple ID。随后它会登录到我们的 Apple Developer 账户。请按照终端窗口中的步骤操作。
  • 你希望如何注册你的设备? 选择 网站,这会生成一个可在 iOS 设备上打开的注册链接。

2

下载并安装配置文件

在设备的浏览器中,打开上一步提供的链接,并点击 下载配置文件按钮

打开 设置 应用,这会提示我们注册设备。

点击 安装 来注册 iOS 设备。

配置文件安装完成后,我们的设备会跳回网页浏览器,并显示一条成功消息,表示该过程已完成。

iOS 设备的开发构建

1

创建

要在 iOS 设备上创建开发构建,请确保在 build.development 配置下:

  • eas.json 中将 developmentClient 设置为 true,默认配置已经完成了这一点。
  • 然后运行 eas build 命令,指定 ios 作为平台,development 作为构建配置:
Terminal
eas build --platform ios --profile development

当我们第一次创建构建时,此命令会提示我们回答以下问题:

  • 你的 iOS bundle identifier 应该是什么?Return 选择此提示提供的默认值。如果尚未定义,这将把 ios.bundleIdentifier 添加到 app.json 中。
  • 你想登录到你的 Apple 账户吗?。由于我们是第一次创建开发构建,它会要求我们 生成一个新的 Apple Distribution Certificate。两次都按 Y
  • 选择一个用于 ad hoc 构建的设备。这是关键步骤,这也是我们之前必须先注册配置文件的原因。我们可以在这里选择一个或所有已注册设备,然后按回车,稍后将该构建安装到这些设备上。

回答完后,构建将进入队列,我们可以通过 EAS CLI 提供的链接在 EAS 仪表盘中跟踪其进度:

构建详情页面包含什么?

构建详情页面会显示构建类型、配置、Expo SDK 版本、应用版本、构建号、最后一次提交哈希,以及发起构建的开发者或账户所有者身份。

在上图中,构建产物 的当前状态显示构建正在进行中。完成后,此部分将提供下载构建的选项。日志 会概述 EAS Build 上 iOS 构建过程中执行的每一步。为了简洁起见,这里我们不会逐步展开每一步。要了解更多,请参阅 iOS 构建过程

什么是 iOS bundle identifier?

ios.bundleIdentifier 是我们应用的唯一名称。如果我们现在发布应用,Apple App Store 会使用这个属性及其值来在商店中识别我们的应用。

这种命名格式定义为 host.owner.app-name。例如,我们的示例应用使用的是 com.owner.stickersmash,其中 com.owner 是域名,stickersmash 是我们的应用名称。

2

安装

构建完成后,构建产物部分会更新,表示构建已完成:

这一部分提供了在 iOS 设备上运行开发构建的可用方法:Expo Orbit 和安装按钮。

Expo Orbit 可以让你在 iOS 设备上无缝安装开发构建。使用此方法:

  • 使用 USB 将 iOS 设备连接到开发机器。
  • 打开 Orbit 菜单栏应用。
  • 在 Orbit 应用中选择 设备
  • 在 EAS 仪表盘中,位于 构建产物 下,点击 使用 Orbit 打开

构建安装完成后,Orbit 应用会在设备上启动该开发构建。

替代方案:使用安装按钮和二维码

构建产物 部分中的 安装 按钮会生成一个二维码,便于安装:

  • 点击 安装,显示包含二维码的弹窗。
  • 使用 iOS 设备的相机扫描二维码,打开链接并点击以在设备上下载开发构建。

3

运行

在项目目录中运行 npx expo start 命令,启动开发服务器:

Terminal
npx expo start
  • 在设备上,点击应用图标打开开发构建。
  • 通过确保我们同时登录了 EAS CLI 和开发构建,使用账户同步功能。既然我们已经登录了 EAS CLI,下一步就是通过开发构建的界面登录。
  • 点击 获取开发服务器,并从开发服务器下方的列表中选择正在运行的服务器。

总结

Chapter 4: Create and run a cloud build for iOS device

We successfully used EAS Build to create and run development builds on iOS devices.

In the next chapter, learn how to configure our app config to install multiple app variants on a single device.

Next: Chapter 5: Configure multiple app variants