Saving Private IPA and APK Builds from Fabric

Victor Bezrodin
@RosberryApps
Published in
6 min readJul 17, 2019

Each and every mobile app development company has to often face the situation that requires dozens of tests for a freshly-installed build or involves multiple cross-checks to ensure that migration from an older version to a newer one has not resulted in possible data loss. To do this QA guys have to over and over again reinstall one and the same build after each test. Sure thing all this takes a good deal of time and invites a reasonable question: ‘Might there be any option to save all those efforts?’ There should be and I guess many. However, in this article we will share our current experience which has already helped us to manage our time in a much better way.

Actually, like many in the industry to distribute builds we use a widely-known Fabric.io. It’s a pretty convenient service that allows you to install test versions of the application onto your devices. But in order to reinstall a build, you have to download it anew. Yet again it’s time-consuming and creates some additional load on your wi-fi channel. What do we do? We store the build downloaded from Fabric locally on a laptop or a desktop computer, and install it through Terminal onto a test device connected to the computer.

Requirements

To download iOS and Android app builds from Fabric.io for subsequent installation via Terminal, we will need the following:

  1. Charles Proxy (or similar, such as Fiddler, Burp Suite). By the way, Charles has a free 30-day trial period.
  2. Any Internet browser.
  3. ‘Beta’ app installed on a test mobile device.
  4. Internet connection.
  5. ADB tools or Android Studio to install apk builds.
  6. ideviceinstaller or Xcode to install ipa builds.

☝️ Further steps described shall be interpreted as taken under macOS. At the same time the steps to be taken under Windows would be much the same.

Configuring Charles to Intercept HTTPS Traffic From Your Devices

To start with, let’s first launch Charles on the computer. I prefer to use the ‘Sequence’ query representation.

Then we should specify the proxy on your devices.

iOS:

1. Settings >Wi-Fi >Your_Network >HTTP PROXY >Manual

2. Specify the IP address of the computer which is used to run Charles and specify port 8888.

3. Open Safari and go to https://chls.pro/ssl to confirm the installation of the proposed certificate.

4. If the iOS version on your iOS device is 10.3 or higher, open Settings and go to General > About > Certificate Trust Settings, find the Charles Proxy certificate, switch the toggle to “On” to trust the installed certificate.

Android:

1. In the Wi-Fi settings, register the proxy manually, specifying the IP of your computer and port 8888.

2. Open Chrome and go to https://chls.pro/ssl

3. Agree to install the certificate or install the downloaded certificate manually through Settings >Security >Credential Storage >Install from device storage.

Charles:

Enable SSL Proxying for the host from which the builds are downloaded:

Option 1:

  1. Open a Charles window.
  2. Launch ‘Beta’ app on the target device, select the test application and click ‘Download’.
  3. In Charles you will see a request to the address https://distributions-crashlytics-com.s3.amazonaws.com
  4. Right click it and select ‘Enable SSL Proxying’ in the menu that pops down.

Option 2:

  1. Open Charles >Proxy >SSL Proxy Settings…
  2. In ‘SSL Proxy Settings’ window choose the SSL Proxying tab to tick ‘Enable SSL Proxying’

Click ‘Add’ and type distributions-crashlytics-com.s3.amazonaws.com in the Host. Then type in 443 as the port number and click ‘OK’.

Saving the Installation File Locally to Your Computer

  1. To filter the queries we need, type in ‘distr’ in the field titled ‘Filter’ (in the Sequence display mode).
  2. Launch Beta app on the target device, select the test application and click ‘Download’.
  3. Wait for the app to be downloaded in full and right click the app download query processed and select ‘Save Response’ in the drop-down menu.
  4. When saving, specify the build number in the file name. If you ask me, for my own purposes I use the template which is like appname_buildnumber.ipa or appname_buildnumber.apk and save to the selected directory.

Important: If the size of the build exceeds 100Mb, Charles for some reason can not save it correctly. In this case, in order to get a setup file you should right click the build download request string, then choose ‘Copy URL’, and after that paste the link into the browser to confirm the file download.

Installation and Removal of Android-based Test Builds via Terminal

1. Connect the device to a computer, open Terminal and enter the command adb devices

If the response is ‘daemon started successfully’, then proceed to the installation of the build (point 3). If it returns an error, then you need to install ‘adb’.

2. Under macOS, you can install adb as part of the ‘platform-tools’.

To do this, install ‘homebrew’ in Terminal.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install ‘platform-tools’ using the command:

brew install homebrew/cask/android-platform-tools

3. To install the application, connect the device using a data cable. Allow debugging via USB on the device (Android).

Launch Terminal and enter:

adb install -r path/appname.apk

Adding the ‘-r’ flag allows to replace an already installed application on installation.

‘path’ is the path to the folder where the ‘apk file’ is located.

4. To uninstall the app via Terminal, use the command:

adb uninstall com.test.app

where ‘com.test.app’ is the Bundle ID of the test app.

The BundleID of the test application can be found through the Terminal. To do this, launch the test application.

Enter the command:

adb shell dumpsys window windows | grep "mCurrentFocus"

Installation and Removal of the iOS-based Test Builds via Terminal

1. Connect the device to a computer, open Terminal and enter the command:

ideviceinstaller -l

If the response contains the list of the applications installed on the device, then proceed to the installation of the build (point 3).

2. If it returns an error, then you should install ‘ideviceinstaller’ or make it work. Having faced with a number of errors, we actually worked out the following sequence of actions to make ‘ideviceinstaller’ work.

Open Terminal and enter the following commands in the right order:

Connect the test iOS device and select ‘Trust’ in the request for permission to connect the computer to this device.

After that, execute the following command in Terminal:

sudo chmod -R 777 /var/db/lockdown/

3. To install the test application in Terminal, enter the following command:

ideviceinstaller -g path/appname.ipa

Adding the -g flag allows to upgrade an already installed application on installation.

‘path’ is the path to the folder where the ‘ipa file’ is located.

4. To uninstall the app via Terminal use the command:

ideviceinstaller -U com.test.app

where ‘com.test.app’ is the Bundle ID of the test app.

The BundleID of the test application can be found through the Terminal. To do this, connect test iOS device.

Enter the command:

ideviceinstaller -l | grep 'Appname'

where ‘Appname’ is the name of the app installed.

Conclusion

That’s all about it. Now you know how to save the test build locally and install to the test device via Terminal. I think this method can work not only with the builds obtained from Fabric. Hope this experience could also work for you and save a lot of time and effort.

--

--