react-nativeexpoexpo-orbit

How can I install and launch a locally built .ipa or .apk from the command line without drag-and-drop in Expo Orbit?


How can I install and launch a locally built .ipa or .apk from the command line without drag-and-drop in Expo Orbit?

I often build my Expo project locally using:

eas build --local --platform ios/android

However, after the build is complete, I have to manually drag and drop the generated .ipa or .apk file into the Expo Orbit menu bar app to install it on my device. This step is tedious and time-consuming.

enter image description here

Desired Solution

I would like to automate this process by specifying the path to the generated build file and the target device directly from the command line, something like:

eas build:run \
  --local \
  --pathToIPAorAPK build-1234567890.ipa/apk \
  --deviceId myIPhoneOrAndroidID

This would allow me to skip the drag-and-drop step entirely and install the app programmatically.

What I Found so far

I came across this InstallAndLaunchApp.ts file in the Expo Orbit source code, which suggests that the CLI might already support installing and launching apps from the command line by passing appPath and deviceId.

However, I’m unsure how to use this functionality.

Then I also tried eas cli but no luck there too.

$ eas build:run --help
run simulator/emulator builds from eas-cli

USAGE
  $ eas build:run [--latest | --id <value> | --path
    <value> | --url <value>] [-p android|ios] [-e <value>]
    [--offset <value>] [--limit <value>]

FLAGS
  -e, --profile=PROFILE_NAME    Name of the build profile used to
                                create the build to run. When
                                specified, only builds created with
                                the specified build profile will be
                                queried.
  -p, --platform=(android|ios)
  --id=<value>                  ID of the simulator/emulator build
                                to run
  --latest                      Run the latest simulator/emulator
                                build for specified platform
  --limit=<value>               The number of items to fetch each
                                query. Defaults to 50 and is capped
                                at 100.
  --offset=<value>              Start queries from specified index.
                                Use for paginating results.
                                Defaults to 0.
  --path=<value>                Path to the simulator/emulator
                                build archive or app
  --url=<value>                 Simulator/Emulator build archive
                                url

Seems like eas build:run does not have option to run on connected devices. Or am I looking wrong command?

Question

  1. Is there a built-in way to install and launch .ipa or .apk files using the command line in Expo Orbit?
  2. If not, is there a workaround to automate this process without manual intervention?

Any guidance or examples would be greatly appreciated!


Solution

  • See the full answer from the Expo team https://github.com/expo/orbit/issues/239#issuecomment-2657991825.

    Summary

    Option 1.A: Install IPA/APK to Device via Terminal

    /Applications/Expo\ Orbit.app/Contents/Resources/orbit-cli-arm64 \
    install-and-launch \
    --app-path /Users/xyz/host.exp.Exponent.ipa \
    --device-id 00008130-00084C910021401C
    

    Option 1.B: Install IPA/APK to Device via Alias Command

    Step 1: Create an Alias

    alias orbit-launch='/Applications/Expo\ Orbit.app/Contents/Resources/orbit-cli-arm64 install-and-launch'
    

    Step 2: Run the Same Command Using the Alias

    orbit-launch \
    --app-path /Users/xyz/host.exp.Exponent.ipa \
    --device-id 00008130-00084C910021401C
    

    Option 2: Install IPA/APK to Device via Finder Context Menu

    Install via Orbit

    Personally, I prefer Option 1.B: Install IPA/APK to Device via Alias Command.

    Pro tip:

    adb devices -l  # Shows list of Android devices
    xcrun xctrace list devices # Shows list of iOS devices/simulators
    

    Pro tip: update

    on Android the Orbit CLI uses the device "name" as the id which is different from adb devices, in order to get the correct name for your device you can run /Applications/Expo\ Orbit.app/Contents/Resources/orbit-cli-arm64 list-devices -p android

    see original comment

    Step 1: Add to your shell

    alias orbit-list-android-devices="/Applications/Expo\ Orbit.app/Contents/Resources/orbit-cli-arm64 list-devices -p android"
    alias orbit-list-ios-devices="/Applications/Expo\ Orbit.app/Contents/Resources/orbit-cli-arm64 list-devices -p ios"
    

    Step 2: list iOS/Android devices

    orbit-list-android-devices
    orbit-list-ios-devices