New FastLane Plugin to Upload iOS Binary With altool

DZone 's Guide to

New FastLane Plugin to Upload iOS Binary With altool

Learn about altool, a plugin for FastLane which allows you to upload iOS binary to iTunes Connect for continuous deployment, and how to set up and use it.

· Mobile Zone ·
Free Resource

Apple doesn't want us to enable continuous deployment for whatever reason. There is no API to deal with iTunes Connect and Apple still wants to approve your apps. Apple's own Continuous Integration server a.k.a. Xcode Server doesn't allow us to upload the IPA files to iTunes Connect. The archive process creates an ipa file but stops there. We still need to rely on Fastlane or manual processes to upload the build to iTunes Connect. In the previous blog post, we saw five ways to upload iOS binaries to iTunes Connect. In this post, we will go through the Fastlane plugin altool that I wrote to upload the iOS binary to iTunes Connect using altool. You can find the details of the plugin here on GitHub.

Why I Wrote This Plugin

Fastlane has solved the problem of uploading the iOS binary to iTunes Connect with tools like deliver and pilot so that we can script the interaction with iTunes Connect. However, Fastlane uses the iTMSTransporter tool to upload the binaries and dealing with iTunes Connect, which is a tricky and lengthy approach. There was an issue on GitHub to discuss the use of altool over iTMSTransporter but the author decided to use iTMSTransporter to deliver tool.

altool is a command line interface for the Application Loader and seems slicker than iTMSTransporter. We don't need to install this utility explicitly, it comes up with the latest Xcode. Apple has brief documentation of altool here. With Fastlane, there was no way to use this tool, so I thought it would be easy to write a plugin so that we can upload binaries to iTunes Connect.

How to Use the altool Plugin

Using the altool plugin is as easy as using other plugins. To get started, add it to your project by running:

fastlane add_plugin altool

The only pre-requisite of this plugin is you have to have Fastlane setup, this plugin has a configurable Apple ID and password but you probably don't want to code those values in the configuration. You need to have Fastlane set up with a FASTLANE_USER and FASTLANE_PASSWORD environmental variable setup. Fastlane will ask  when you run fastlane init, but if not, you have to set these variables.

You can set that easily for bash shell:

$ export FASTLANE_USER="your_apple_id@yourcompany.com";
$ export FASTLANE_PASSWORD="your_super_xecret_password";

You can do the same for your choice of the shell if you aren't using bash. This plugin can be used for uploading a generated ipa file using Gym to iTunes Connect.

Once installed, we can easily configure the plugin using the following configuration parameters:

        altool_username: ENV["FASTLANE_USER"],
        altool_password: ENV["FASTLANE_PASSWORD"],
        altool_app_type: "ios",
        altool_ipa_path: "./build/Your-ipa.ipa",
        altool_output_format: "xml",

You can configure this once you have created an iOS binary or ipa file using Gym.

A Little Bit About Security

In the above configuration, we have used environmental variables for secure configuration. It's up to you how you want to use those credentials securely. When the altool plugin runs, it might print the username and password to the console commands, pipe the output to /dev/null or use a similar approach so that Fastlane doesn't print the command to console. Select the right way to secure your details.

Example Project

There is an example project called Altool-Demo available on GitHub which has its own README. Feel free to check out the project and try it yourself. This project uses a dummy file so it fails the validation, but if you got real ipa, then it would be uploaded to iTunes Connect (hopefully).

This plugin is just a Ruby wrapper on Apple's command line tool altool; if that altool works, then this plugin should 100% work. I would like to try this on a real app and see how it performs. Try it at your own risk. Good luck and happy continuous delivery for iOS apps.

fastlane, ios, mobile, mobile app development

Published at DZone with permission of Shashikant Jagtap , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}