To view this content, buy the book! 😃🙏
Or sign in if you’ve already purchased.
If you’re jumping in here, git checkout 3_1.0.0 (tag 3_1.0.0)
git checkout 3_1.0.0
Deploying an SPA is straightforward:
cd build/ && vercel
Deploying native apps is much more involved. Fortunately, Expo does a lot to make the process smoother. First, we optimize our assets (for example, compressing images):
npm i -g sharp-cli
The next step is building, but before we do that, we need to add some fields to our app.json:
The first digit of an iOS build number cannot be 0, so the lowest number possible is 1.0.0.
On Android, permissions are requested at time of install (versus iOS, which are requested via popup dialogs while the app is being used). android.permissions lists all permissions the app needs, for example ["CAMERA"] for an app that takes pictures.
Now we can build for the platform(s) we want:
npx expo build:ios
npx expo build:android
npx expo build:web
After build:web, our static assets will be in web-build/, so we’d do, for instance, cd web-build/ && vercel.
cd web-build/ && vercel
After build:ios or build:android, we upload to the app stores:
npx expo upload:ios
npx expo upload:android
Both commands walk us through the process. In each case, we’ll need a developer account. Creating a developer account for uploading apps to the Google Play Store has a one-time fee of $25, and the iOS App Store is $99/year. The iOS App Store also has a manual review process that can take a couple days.
So far we’ve gone through the process for deploying apps for the first time. When we make updates to our app and want to redeploy, there are two different ways to do it, depending on what types of changes we made.
If we made changes to the version of Expo or to certain fields in app.json, like name, icon, splash, ios, android, etc., then we need to re-run the build and upload commands.
So when the user opens the app, the version of the app code that’s on the device will run. The new version will be downloaded in the background and used the next time the app is opened. If we set "fallbackToCacheTimeout": 30000 (30 seconds, the default value), then this will happen: