本文档于 2022 年 8 月存档,不会收到任何进一步更新。请改用 EAS 更新。了解更多
¥This doc was archived in August 2022 and will not receive any further updates. Please use EAS Update instead. Learn more
在开发项目时,你正在计算机上编写代码,当你使用 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 的设备都应该能够访问你的项目。这使得在手机上打开项目或将其发送给不在同一 LAN 上的其他与你协作的人变得更加容易。
¥exp.direct
is a domain we use for tunneling, so that even if you're
behind a VPN or firewall, any device on the internet that has your URL
should be able to access your project. This makes it much easier to open
your project on your phone or send it someone else you're collaborating
with who isn't on the same LAN.
但由于打包程序和开发服务器在你的计算机上运行,因此如果你关闭注意本电脑或停止 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 版本)
¥sdkVersion (standalone apps are built to support only a single SDK version)
platform
releaseChannel
以下流程图显示了我们如何确定将哪个版本返回给用户:
¥The following flowchart shows how we determine which release to return to a user:
¥Deploying to the App Store and Play Store
当你准备好将应用分发给终端用户时,你可以创建独立的应用二进制文件(ipa 或 apk 文件)并将其放入 iOS App Store 和 Google Play Store。
¥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.
¥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 版本
¥Increment the Expo SDK Version
更改 ios
、android
或 notification
键下的任何内容
¥Change anything under the ios
, android
, or notification
keys
更改你的应用 splash
¥Change your app splash
更改你的应用 icon
¥Change your app icon
更改你的应用 name
¥Change your app name
更改你的应用 owner
¥Change your app owner
更改你的应用 scheme
¥Change your app scheme
改变你的 facebookScheme
¥Change your facebookScheme
更改 assetBundlePatterns
下的打包资源
¥Change your bundled assets under 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.
¥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.
由于 Apple 施加的限制,共享已发布应用的最佳方式是使用 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
你可以通过将键 "privacy" 设置为 "public"
或 "unlisted"
,在 app.json 配置文件中设置项目的隐私。
¥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 上的方式类似。未列出的项目 URL 将是秘密的,除非你告诉人们或分享它们。公共项目可能会向其他开发者展示。
¥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.
¥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.
如果你确实希望发布的应用为 'unpublished',请查看我们的 高级发布渠道 指南,其中解释了如何回滚。
¥If you really want your published app to be 'unpublished', check out our guide on Advanced Release Channels, which explains how to roll back.