发布更新


本文档于2022年8月归档,不会再有任何更新。请改用EAS Update。了解更多

在你开发项目的过程中,你会在电脑上编写代码,当你使用 Expo CLI 时,服务器和 Metro 打包器会在你的电脑上运行,将所有源代码打包,并通过一个 URL 提供访问。你正在开发的项目的 URL 大概看起来像这样:exp://i3-kvb.ccheever.an-example.exp.direct:80

🌐 While you're developing your project, you're writing code on your computer, and when you use Expo CLI, a server and the Metro bundler run on your machine and bundle up all your source code and make it available from a URL. Your URL for a project you're working on probably looks something like this: exp://i3-kvb.ccheever.an-example.exp.direct:80

exp.direct 是我们用来进行隧道传输的域名,这样即使你在 VPN 或防火墙后面,任何在互联网上知道你 URL 的设备都应该能够访问你的项目。这使得在手机上打开你的项目或者发送给与你合作但不在同一局域网的人变得容易得多。

但是由于打包器和开发服务器正在你的电脑上运行,如果你关闭注意本电脑或停止 Expo CLI,就无法通过该 URL 加载你的项目。“发布”是我们用来部署项目的术语。它会让你的项目在一个持久的 URL 上可用,例如 https://expo.dev/@community/native-component-list,可以通过 Expo Go 应用打开。它还会将你应用中的所有图片、字体和视频上传到 CDN(在这里了解更多)。

🌐 But since the bundler and development server are running on your computer, if you turn off your laptop or stop Expo CLI, you won't be able to load your project from that URL. "Publish" is the term we use for deploying your project. It makes your project available at a persistent URL, for example https://expo.dev/@community/native-component-list, which can be opened with the Expo Go app. It also uploads all of your app images, fonts, and videos to a CDN (read more here).

如何发布

🌐 How to publish

要发布一个项目,运行 expo publish。无需任何设置,直接创建一个新项目并发布它,即使不做任何修改,你也会看到它可以正常工作。

🌐 To publish a project, run expo publish. No setup is required, go ahead and create a new project and publish it without any changes and you will see that it works.

当你这样做时,打包工具会压缩你所有的代码,并生成两个版本的代码(一个用于 iOS,一个用于 Android),然后将它们上传到 Expo 提供的免费托管服务。你会得到一个链接,例如 https://exp.host/@ccheever/an-example,任何人都可以通过这个链接加载你的项目。

🌐 When you do this, the bundler will minify all your code and generate two versions of your code (one for iOS, one for Android) and then upload those to a free hosting service provided by Expo. You'll get a link like https://exp.host/@ccheever/an-example that anyone can load your project from.

如果你还没有优化你的资源,当你运行 expo publish 时,系统会提示你并询问是否想要进行优化。这与运行 npx expo-optimize 的效果相同,会压缩你项目中的所有 PNG 和 JPEG 文件。

🌐 If you haven't optimized your assets yet you will be prompted and asked if you'd like to do so when you run expo publish. This has the same effect as running npx expo-optimize and will compress all of the PNGs and JPEGs in your project.

每当你想部署更新时,只需再次点击发布,下次用户打开时就会立即看到新版本。

🌐 Any time you want to deploy an update, hit publish again and a new version will be available immediately to your users the next time they open it.

我的用户将获得什么版本的应用?

🌐 What version of the app will my users get?

你的用户将获得推送到 发布渠道 的最新兼容版本。影响兼容性的因素有:

🌐 Your users will get the most recent compatible release that was pushed to a release channel. Factors that affect compatibility:

  • sdkVersion(独立应用仅支持单个 SDK 版本)
  • platform
  • releaseChannel

以下流程图显示了我们如何确定将哪个版本返回给用户:

🌐 The following flowchart shows how we determine which release to return to a user:

部署到 App Store 和 Play Store

🌐 Deploying to the App Store and Play Store

当你准备将应用分发给终端用户时,你可以创建一个独立的应用二进制文件(ipa 或 apk 文件),并将其放入 iOS 应用商店和 Google Play 商店。

🌐 When you're ready to distribute your app to end-users, you can create a standalone app binary (an ipa or apk file) and put it in the iOS App Store and the Google Play Store.

独立应用会自动检查你应用发布的网址上的更新,如果你发布了更新,下次用户打开应用时,他们会自动下载新版本。

🌐 The standalone app knows to look for updates at your app's published url, and if you publish an update then the next time a user opens your app they will automatically download the new version.

将资源上传至 CDN

🌐 Uploading Assets to the CDN

为了将资源上传到 CDN,必须在应用的代码中明确地引用它们。有条件地引用资源会导致 Metro 打包工具无法检测到它们,因此在发布项目时这些资源将不会被上传。

🌐 In order for assets to be uploaded to the CDN, they must be explicitly required somewhere in your application's code. Conditionally requiring assets will result in the Metro bundler being unable to detect them and therefore they will not be uploaded when you publish your project.

局限性

🌐 Limitations

某些原生配置无法通过发布来更新

🌐 Some native configuration can't be updated by publishing

如果你在 app.json 中进行以下任何更改,你将需要重新构建应用的二进制文件,才能使更改生效:

🌐 If you make any of the following changes in app.json, you will need to re-build the binaries for your app for the change to take effect:

  • 增加 Expo SDK 版本
  • 更改 iosandroidnotification 键下的任何内容
  • 更改你的应用 splash
  • 更改你的应用 icon
  • 更改你的应用 name
  • 更改你的应用 owner
  • 更改你的应用 scheme
  • 更改你的 facebookScheme
  • assetBundlePatterns 下更改你的打包资源

此外,对 Firebase 配置文件(google-services.json 和 GoogleService-Info.plist)中的键进行更改将需要重新构建二进制文件才能在 iOS 或 Android 独立应用中生效。

🌐 Additionally, changes to keys in Firebase configuration files (google-services.json and GoogleService-Info.plist) will require re-building the binaries to take effect in the iOS or Android standalone app.

在 iOS 上,你无法共享已发布的链接

🌐 On iOS, you can't share your published link

当你发布时,任何 Android 用户都可以立即在 Expo Go 中打开你的应用。

🌐 When you publish, any Android user can open your app inside Expo Go immediately.

由于苹果公司施加的限制,共享已发布应用的最佳方式是使用 Expo 的构建服务构建原生二进制文件。你可以使用 Apple TestFlight 与测试人员共享应用,也可以将其提交到 iTunes Store 以更广泛地分享。

🌐 Due to restrictions imposed by Apple, the best way to share your published app is to build a native binary with Expo's build service. You can use Apple TestFlight to share the app with your testers, and you can submit it to the iTunes Store to share more widely.

隐私

🌐 Privacy

你可以在你的 app.json 配置文件中设置项目的隐私,通过将键 "privacy" 设置为 "public""unlisted"

🌐 You can set the privacy of your project in your app.json configuration file by setting the key "privacy" to either "public" or "unlisted".

这些选项的工作方式与 YouTube 上的类似。未列出的项目网址将是保密的,除非你告诉别人或分享它们。公开项目可能会被显示给其他开发者。

🌐 These options work similarly to the way they do on YouTube. Unlisted project URLs will be secret unless you tell people about them or share them. Public projects might be surfaced to other developers.

如何删除我发布的托管 Expo 项目?

🌐 How do I remove a managed Expo project that I published?

受管理应用的默认隐私设置是 unlisted,因此除非你与他们分享链接,否则没人能找到你的应用。

🌐 The default privacy setting for managed apps is unlisted so nobody can find your app unless you share the link with them.

如果你真的想让你发布的应用变为“未发布”,请查看我们的《高级发布渠道》指南,其中解释了如何回滚。

🌐 If you really want your published app to be 'unpublished', check out our guide on Advanced Release Channels, which explains how to roll back.