Skip to content

RobinCsl/build-standalone-expo-app

Repository files navigation

Build Standalone Expo .apk and .ipa with Turtle CLI

This is a condensed version which only shows the commands for each section.

We will go through the following steps:

  1. Install Turtle CLI
  2. Create a dummy application
  3. Publish Expo app on local server
  4. Create APK file -- Android
  5. Create IPA file -- iOS
  6. Distribute and install

To install Turtle CLI, run

$ npm install -g turtle-cli

Let's create a dummy application using Expo CLI. In your terminal, run

$ npx expo init ExampleApplication

Add the keys "bundleIdentifier" under "ios", and "package" under "android" in your app.json file:

...
    "ios": {
      ...
      "bundleIdentifier": "com.example.exampleApplication",
      ...
    },
    "android": {
      ...
      "package": "com.example.example_application",
      ...
    }
...

Assuming that your local web server will be running on http://127.0.0.1:8000, export the app with

$ expo export --dev --public-url http://127.0.0.1:8000
...
Export was successful. Your exported files can be found in dist

Serve the dist directory on your web server (and make sure it's available at the same URL that you chose for the flag --public-url above). For example, run

$ npx http-server -p 8000 dist

Note: if for some reason you need to re-export your application (because you modified your app.json file since the last export, for instance), you must first remove the dist directory:

# assuming you are at the root of the project
$ rm -rf dist
$ expo export --dev --public-url http://127.0.0.1:8000

Verify that your local server is running, e.g.

$ curl http://127.0.0.1:8000/android-index.json
{"name":"ExampleApplication","slug":"ExampleApplication","version":"1.0.0","orientation":"portrait","icon":"./assets/icon.png","splash":{"image":"./assets/splash.png","resizeMode":"contain","backgroundColor":"#ffffff","imageUrl":"http://127.0.0.1:8000/assets/201a91bd1740bb1d6a1dbad049310724"}...

If you know which Expo SDK version you are going to use, you can run

$ turtle setup:android --sdk-version <SDK-VERSION>

Create Keystore

You can generate a keystore file with the following command

$ keytool -genkeypair -v -keystore keystore.jks -alias keyalias -keyalg RSA -keysize 2048 -validity 9125

Build APK

Make sure that you are serving the dist directory on http://127.0.0.1:8000 as explained above in Run a local server, and run

EXPO_ANDROID_KEYSTORE_PASSWORD=<KEYSTORE_PASSWORD> \
EXPO_ANDROID_KEY_PASSWORD=<KEY_PASSWORD> \
turtle build:android \
  --type apk \
  --keystore-path <KEYSTORE_PATH> \
  --keystore-alias <KEYSTORE_ALIAS> \
  --allow-non-https-public-url \
  --public-url http://127.0.0.1:8000/android-index.json

Once the build finishes, take note of the location of your build .apk file. For example,

Feb 5 08:34:22 turtle[11626] INFO:  copied build to ~/expo-apps/@anonymous__ExampleApplication-6d7e1749c5b64bd0851525b0c7eec780-signed.apk
  platform: "android"
  buildPhase: "copying build artifact"

First, verify that your local server is running, e.g.

$ curl http://127.0.0.1:8000/ios-index.json
{"name":"ExampleApplication","slug":"ExampleApplication","version":"1.0.0","orientation":"portrait","icon":"./assets/icon.png","splash":{"image":"./assets/splash.png","resizeMode":"contain","backgroundColor":"#ffffff","imageUrl":"http://127.0.0.1:8000/assets/201a91bd1740bb1d6a1dbad049310724"...

If you know which Expo SDK version you are going to use, you can run

$ turtle setup:ios --sdk-version <SDK-VERSION>

Create Signing keys

See this section in the article.

Build IPA

Make sure that you are serving the dist directory on http://127.0.0.1:8000 as explained Run a local server, and run

EXPO_IOS_DIST_P12_PASSWORD=<PASSWORD HERE> \
turtle build:ios \
  --team-id <YOUR_TEAM_ID> \
  --dist-p12-path </path/to/your/dist/cert.p12> \
  --provisioning-profile-path </path/to/your/provisioning/profile.mobileprovision> \
  --allow-non-https-public-url \
  --public-url http://127.0.0.1:8000/ios-index.json

Once the build finishes successfully, you should get the path to your .ipa file.

on Android

If you connect an Android device to your computer, you should be able to run:

$ adb devices
emulator-5554	device

to list all your connected Android devices and emulators. (In my case, only the emulator is "connected".)

It is then possible to install the .apk file by running:

$ adb -s emulator-5554 install <PATH_TO_YOUR_APK_FILE>
Performing Streamed Install
Success

on iOS

Caveat: I could not fully test this section, so my apologies if this does not work as intended.

Since you should have Xcode, the most promising solution is in this guide. It also mentions other ways to install the .ipa file.


I hope this was helpful. If you have any questions or comments, please drop me a line on Twitter or create an issue in this repository. I shall reply as soon as possible.

Resources

About

Accompanying repo for my article "Build Standalone Expo .apk and .ipa with Turtle CLI"

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published