Over-the-air updates from Expo are now even easier to use!

Eric Samelson
Exposition
Published in
3 min readMay 11, 2020

--

Last month, we released the first version of expo-updates along with SDK 37. This library allows you to use Expo’s over-the-air updates in any React Native app. We’re excited to see many developers are already using this library through our Bare workflow, and we’re thankful for all your great feedback.

Today we’re releasing expo-updates@0.2.0, which simplifies the workflow around updates. Now, if you want to add expo-updates to an existing React Native app, here’s what you do:

  1. Install and set up the library, and continue as usual.
  2. When you want to release an update, just publish it.
  3. That’s it! No extra steps needed.

If you’re already using expo-updates@0.1.x, or if you’re curious, read on for more details about what’s changed!

Build-time updates

Previously, release builds of apps with expo-updates would embed the latest published update of your app in the binary. Now, release builds of both iOS and Android apps will create and embed a new update from the JavaScript source on disk at build-time. This new update will not be published automatically and will exist only in the binary with which it was bundled.

This means you no longer need to run expo publish before creating a release build for the first time.

This change makes the build process more flexible and similar to most typical React Native apps. We hope it will make getting started with expo-updates even easier and faster.

If you’re running expo-updates@0.1.x, you can upgrade to 0.2.0 without using build-time updates. However, you’ll have the option to switch (see instructions at the bottom of this post) and we highly recommend that you do so!

Build-time updates have no manifest

Another important change to note is that build-time updates do not have a manifest, so Updates.manifest will be empty when an embedded update is running. This means that, if you rely on Updates.manifest in your application code, you’ll need to handle the case where it’s an empty object.

To help with this, we’ve exposed two important values as separate properties. First, we expose a unique identifier for your update in the Updates.updateId property. (This UUID is defined for every update, including published ones, so it can be used as a replacement for the manifest revisionId field.) Second, we’ve also exposed the release channel of your build in the Updates.releaseChannel property.

Upgrading from 0.1.x

Newly initialized projects with expo-updates@0.2.0 (which includes all projects created with expo init, starting today) will use build-time updates by default. If you’re upgrading from 0.1.x, the old workflow is still currently supported, but we strongly recommend you switch to the build-time update workflow by making these five changes in your project:

  • Update to expo-updates@0.2.0 or later, and expo@37.0.10 or later (or expo-asset@8.1.5 if you depend directly on expo-asset). Also, make sure you’re running the latest expo-cli.
  • Delete the app.manifest and app.bundle files from your Xcode project and android/app/src/main/assets directory.
  • Add a metro.config.js file to your project with these contents.
  • In your Xcode project, open the “Bundle Expo Assets” / “Bundle React Native code and images” build phase and replace the contents with the following:
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh
../node_modules/expo-updates/scripts/create-manifest-ios.sh
  • Open the “Start Packager” build phase and remove the following lines, if they exist:
if [ \"$CONFIGURATION\" == \"Release\" ]; then
exit 0;
fi
  • In android/app/build.gradle, apply the following diff:
project.ext.react = [
entryFile: "index.js",
- bundleInRelease: false,
enableHermes: false
]
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native/react.gradle"
-apply from: "../../node_modules/expo-updates/expo-updates.gradle"
+apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"

Again, the old workflow from 0.1.x is still supported in this new version, so you can still upgrade to 0.2.0 without following these extra steps. However, we strongly recommend switching to this new workflow.

We have many exciting features planned for expo-updates in the coming months, so stay tuned and keep the feedback coming!

--

--