为 iOS 创建生产版本
了解为 iOS 创建生产版本和自动化发布过程的过程。
在本章中,我们将创建示例应用的生产版本,并使用 TestFlight 提交测试。之后,我们将提交应用进行 App Store 审核,以便上架到 App Store。
🌐 In this chapter, we'll create our example app's production version and submit it for testing using TestFlight. After that, we'll submit them for App Store review to get it on the App Store.

先决条件
🌐 Prerequisites
要在 Apple Play Store 上发布和分发应用,我们需要:
🌐 To publish and distribute an app on the Apple Play Store, we need:
- Apple 开发者账户: 要创建账户,请参阅 Apple 开发者门户。
- 生产构建配置: 确保在你的 eas.json 中存在
production构建配置,它是默认添加的。
iOS 的生产版本
🌐 Production build for iOS
一个生产 iOS 构建 已针对苹果的 App Store Connect 进行了优化,它允许通过 TestFlight 分发构建给测试人员,并通过 App Store 分发给公众用户。这种构建类型无法在模拟器或设备上侧载,只能通过 App Store Connect 分发。
🌐 A production iOS build is optimized for Apple's App Store Connect, which allows distributing builds to testers with TestFlight and public end users through the App Store. This build type cannot be side-loaded on a simulator or device and can only be distributed through App Store Connect.
1
创建分发配置文件
🌐 Create a distribution provisioning profile
在终端中运行 eas credentials 命令,然后根据 EAS CLI 的提示回答以下问题:
🌐 Run the eas credentials command in the terminal and then answer the following prompts by EAS CLI:
- 选择平台 iOS。
- 你想配置哪个构建配置文件? 选择生产环境。
- 你想登录你的 Apple 账户吗? 按 Y。这将登录我们的 Apple 开发者账户。
- 你想做什么? 选择 生成凭据,然后选择 全部:设置构建项目所需的所有凭据。
- 现在,它会提示我们是否想要重复使用之前的分发证书。按 Y。
- 生成新的 Apple 配置文件? 按 Y。这将是生产应用的配置文件。
- 创建配置文件后,按任意 ctrl + c 退出 EAS CLI。
2
创建生产版本
🌐 Create a production build
要使用默认的 production 配置文件创建 iOS 生产版本,请打开终端并执行以下命令。由于 production 已在 EAS 配置中设置为默认配置文件,因此无需使用 --profile 标志显式指定它。
🌐 To create an iOS production build using the default production profile, open your terminal and execute the following command. Since production is set as the default profile in the EAS configuration, there is no need to specify it explicitly with the --profile flag.
- eas build --platform ios该命令将排队构建。在 EAS 仪表板上注意,构建编号会自动递增。
🌐 The command will queue the build. Notice on the EAS dashboard that the Build Number is auto-incremented.
3
将应用二进制文件提交到 App Store
🌐 Submit the app binary to the App Store
要提交从我们最新的 EAS 构建创建的应用二进制文件,请运行 eas submit 命令:
🌐 To submit the app binary created from our latest EAS Build, run the eas submit command:
- eas submit --platform ios运行此命令后,我们需要:
🌐 After running this command, we need to:
- **从 EAS 选择一个构建。**让我们选择最新的构建 ID。
- 按照提示登录我们的 Apple 账户。 当出现 是否重用此 App Store Connect API 密钥? 时,按 Y。
这将触发提交过程。
🌐 This will trigger the submission process.
4
发布内部测试版本
🌐 Release an internal testing version
提交过程完成后,我们需要从网页浏览器登录 Apple 开发者账号。
🌐 After the submission process is complete, we'll need to log in to the Apple Developer account from the web browser.
- 点击 应用,查看应用图标。
- 点击应用名称,然后在导航标签菜单中点击 TestFlight。如果版本刚提交,Apple 处理该版本可能需要几分钟,然后才能通过 TestFlight 进行分发。
信息 仅当你跳过了iOS 设备开发构建章节时: 系统会提示 iOS 应用是否只使用标准/豁免加密? 按 Y 选择此提示提供的默认值。由于我们的应用不使用加密,它会在 Info.plist 文件中设置
ITSAppUsesNonExemptEncryption为NO,并在你将应用发布到 TestFlight/Apple App Store 时管理相关合规性检查。当你发布自己的应用并且使用了加密时,下次可以选择N来跳过此提示。
- 在 App Store Connect 中,进入 内部测试,并创建一个测试组。这将允许我们邀请测试用户。
- 一旦创建了该群组,邮件将会发送给所有测试用户。
- 在电子邮件中,点击 在 TestFlight 中查看,接受邀请,然后点击 安装。
之后,应用将会下载到我们的设备上,以便我们进行测试。
🌐 After that, the app will download on our device so that we can test it.
注意:与内部测试类似,我们也可以创建一个群组,通过 TestFlight 邀请外部测试人员。内部测试的用户上限为 100 人,而 TestFlight 允许将测试版本外部分享给最多 10,000 名测试人员,并提供一个可以公开分享的链接。为了简洁起见,本教程将不涵盖这些步骤。
5
将应用提交到苹果应用商店
🌐 Submit the app to the Apple App Store
要为我们的应用准备提交到 App Store,请转到 App Store 选项卡:
🌐 To prepare our app for App Store submission, go to the App Store tab:
- 提供元数据详细信息,按照苹果的指南提供截图,并在常规下填写详细信息。
- 然后,手动选择构建。
完整的应用商店列表:要准备应用在商店上架,请参阅 创建应用商店素材 了解如何制作截图和预览。
- 一旦我们的应用准备就绪,点击 提交应用审查。之后,苹果会审核我们的应用,如果通过审核,应用将会上架到 App Store。
6
自动提交
🌐 Automated submissions
对于未来的版本,我们可以通过在 eas build 中使用 --auto-submit 标志,将构建创建和 App Store 提交合并为单一步骤,从而简化流程:
🌐 For future releases, we can streamline the process by combining build creation and App Store submission into a single step by using the --auto-submit flag with eas build:
- eas build --platform ios --auto-submit注意: 此命令将自动将你的构建上传到 TestFlight 进行内部测试,但不会自动将你的应用提交到 App Store 审核。当你准备公开发布时,仍需手动将构建从 TestFlight 提升到 App Store。更多信息请参见 应用商店的默认提交行为。
概括
🌐 Summary
Chapter 9: Create a production build for iOS
We successfully created a production-ready iOS build, discussed distribution using TestFlight and Apple App Store using eas submit, and automated the release process with the --auto-submit.
In the next chapter, learn how to use the EAS Update to send OTA updates and share previews with our team.