Skip to content

Containers have been trending for some time now and have seriously changed the way people set up their environments for development, deployment – and more and more – for testing. Efficient use of test automation together with containers – whether the app is done for Android and iOS – have enabled a variety of different setups to become alive (and die) quickly, effectively and yet boosting productivity that people seek with their development workflows today.

In this blog, we’ll take a look at a very concrete example of iOS containerization, how to set up things on the fly and how to further tweak it for an optimal use case.

One of the greatest advantages of Bitbar’s container-based infrastructure is that you can use the Linux and Mac OS servers that are connected to real devices to any kind of tasks that require specialized hardware. For example, these Mac and Linux machines can help you to achieve other things as well and those can be used to build your app too.

Let’s take a look at how you can quickly compile your iOS app in Bitbar Testing.

Using Containers to Build iOS App in Cloud

Compiling your iOS apps in Bitbar Testing

Compiling your apps every time when you commit your code changes to the version control takes significant time and locks the resources (your personal computer) that you could use for other more productive tasks. Especially in iOS development, this is a significant issue mainly because:

  • Cost-efficient use of resources. Not every employee in the organization is using a Mac so everyone keeps tapping the iOS developer’s shoulder for latest developer/appstore/beta/testing build tying the poor developer’s time to repetitive, manual and error-prone task several times a day which breaks the focus and lowers productivity.
  • Faster build-time enables instant testing. Compiling iOS binaries is resource intensive and quite slow. In many cases, you need to compile five target binaries (32bit iPhone, 64bit iPhone, 32bit iPad, 64bit iPad and Simulator) which can take anywhere from 30-60 minutes depending on your app and the hardware you are using for compiling. Needless to say that if you are using your personal Mac for this you can’t do much productive work during the build process.
  • Build and sign with confidence and quickly. You need different kinds of builds and app signing for different purposes: Ad Hoc distribution, Beta distribution, manual testing, automated testing so there are a lot of different versions of the binaries to manage quite often only the iOS developer knows how to create each of these.

Luckily there are open source tools to help automate these otherwise complex, repetitive and error-prone tasks and because you can customize Bitbar Cloud’s containers on the fly you are able to utilize these tools and the vast Mac farm that Bitbar Cloud essentially is to achieve something similar that has been described in this legendary 3×3 blog by LinkedIn.

So, how to get started with container creation and what should go in? First thing first. Check what goes in the container that helps you to enable efficient build and test flow in the cloud.

Enter Fastlane

Fastlane is a really useful collection of command line tools for automating iOS and Android development workflows. We are using these tools internally and using Fastlane for continuous integration with iOS apps is definitely something we’re advocating for other folks as well.

Today we are going to focus on using the Gym command line utility for compiling the iOS target binary for each iOS real device target as part of your automated Bitbar test run. The automated workflow is the following:

  • Check out the latest version of your app’s source code from your repository
  • Compile the target binary for each iOS device type in parallel on individual containers
  • Automatically check that your new binary installs and runs on each iOS device type by running a quick smoke test with Bitbar App Crawler or with your scripted tests (any framework goes).
  • Download the created binary from Bitbar web UI where each build is presented with timestamps, build logs and accompanying test results for anyone in the organization to access. Anyone in the organization can also create new binaries that are built from the latest source code by just triggering a new run in this project.

Step-by-Step: How to Build iOS App in the Cloud

Step #1: First, after you’ve logged in to Bitbar Testing, create a server-side project for yourself. In the project view, you can select any of ‘Server-side’ projects from the dropdown menu. In this example, I’m using “Appium iOS Server-Side”:

iOS Server-side Project for Bitbar Cloud

To run a build job in Bitbar Cloud utilizing a container technology, you can upload a build script instead of tests. In you can determine the build script you just need to upload also some mock.ipa.

Step #2: Next thing to do is to include Fastlane gymfile with build parameters in the script zip package. The gymfile should contain the following lines:

# For more information about this configuration visit
# In general, you can use the options available
# fastlane gym --help
# Remove the # in front of the line to enable the option
scheme "calculator"
sdk "iphoneos10.2"
output_directory "./"
  method: "development",
  uploadSymbols: true,
  uploadBitcode: false

Step #3: In the shell script you need to have the unzip mechanism for all files required for test automation (and build) session. This can be done using the following line:

unzip -u

Next, create a build folder and copy the Gymfile that is included in the zip with fastlaneFiles:

mkdir ~/buildFolder
cp fastlaneFiles/Gymfile ~/buildFolder/
cd buildFolder

Now, close the git repo and copy gymfile into just cloned folder, using the following commands:

git clone "clone-URL"
cp  ./Gymfile ./source_folder/

Step #4: Install Fastlane for more forth use, and go to the source folder:

gem install fastlane
cd source_folder

Run Fastlane build command with the following line:

fastlane gym

And copy compiled .ipa file to output folder so that it appears in Bitbar Cloud UI as “”:

cp ./*.ipa "/Volumes/VMware Shared Folders/test/output-files/”

That’s basically all for configuration!

Step #5: Now, you can upload and run things in Bitbar Cloud.

You’ve already created a server-side project so click green ‘+’ icon on the right-hand side to upload app and test file. include built IPA file

Once you have uploaded all required files, selected devices on which on run package on etc. you can download the that includes the recently built .ipa file. Quick and handy, isn’t it?

Things to take in consideration in compiling apps on Bitbar Testing

This simple example showed the most basic use case for using Bitbar Cloud containers for your automated DevOps workflow. However, there are a few things that you need to take into consideration for more advanced use cases. For instance:

  • Access to private code repositories.
  • Access to apple servers to download customers certificates for Fastlane signing.
  • Custom build script support for special apps.
  • How to configure Fastlane to build different versions (ad-hoc, crashlytics, app-store).
  • How to build customized builds with different resources.
  • Building test packages.

In order to get these done, we’ll be deep-diving on these topics in our forth-coming blogs about using containers for mobile test automation. Meanwhile, please let us know if you have any questions and weigh in a comment in the comment section below!

Happy Testing (with containers), Folks!


Article author