Fastlane Configuration For IOS Application

Burcu K. Kutluay
Mobile App Development Publication
6 min readDec 2, 2019

As an IOS developer, I am curious about DevOps things. To implement Continuous Integration / Deployment processes for the applications I am working on, I want to share my experiences about fastlane.

According to my experiences, Fastlane is a very useful tool to deploy test flight versions and release IOS applications to App Store Connect automatically. Fastlane is able to run tests and create reports. I wanted to implement Fastlane on my project and achieve these goals at first. Good news: It is free!

“fastlane is an open source platform aimed at simplifying Android and iOS deployment.
fastlane lets you automate every aspect of your development and release workflow.” (https://fastlane.tools)

SETUP FASTLANE

It is very easy to setup Fastlane. To start with open terminal on your Mac:

Lets’ Navigate to my specific project folder. My projects folder is here:

I have to install Xcode command-line tools, If you have already installed do not worry, there is no problem :)

Now I should install Fastlane. I used RubyGems, and just type the following command to terminal: sudo gem install fastlane -NV

Just enter the Mac password and wait for the install :)

Gem is installed. Let's create necessary files in the root directory. Now I should init Fastlane to create files. Just type the following command to terminal: fastlane init swift

Well done, welcome to Fastlane! Lets’ continue with a deeper configuration part :) I will just pass it faster now, continue to typing 3 and enter my apple id and password.

Briefly, after that, I will see gem files and Fastlane files are created.

Check your project folder, and in Fastlane folder, you will see Appfile. Just open it and check your information:

TESTFLIGHT DISTRIBUTION ON FASTLANE

It is easy after that. We have Appfile and Fastfile. Our config file will be Fastfile after that. Now we will distribute iOS application to Testfligt.

We need to go back a little bit. Lets clear the terminal, type: clear

We will have a very clear terminal:

Now I should check my project folder, and look at FastFile:

Note that I have schemas on my project. You do not have to config that parameter. I just added the following codes to Fastfile and save. My Fastfile looks like this:

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do
desc “Push a new beta build to TestFlight”
lane :beta do
increment_build_number(xcodeproj: “movieListing.xcodeproj”)
build_app(workspace: “movieListing.xcworkspace”, scheme: “movieListing — Prod”)
upload_to_testflight
end

lane :tests do
run_tests(workspace: “movieListing.xcworkspace”,
devices: [“iPhone 6s”, “iPhone 8”],
scheme: “movieListing — Prod”,
skip_build: true)
end

lane :testsWithoutBuild do
run_tests(
run_tests(workspace: “movieListing.xcworkspace”,
devices: [“iPhone 6s”, “iPhone 8”],
scheme: “movieListing — Prod”),
test_without_building: true)
end

end

Right now, go back to terminal and just type: fastlane

Now final step: We should type 1 and press enter :) Then, we will wait for build…

After waiting, we will see a success message!

I checked on iTunes connect .apple.com for my versions, and I saw my app is successfully uploaded. The first goal is achieved.

I wrote some unit tests for my app and now I want to run tests automatically on Fastlane. Let's move on…

RUNNING UNIT TESTS ON FASTLANE

If you are working on a big-scale project and already have lots of unit-tests written, I recommend you to comment on most of the test classes and try for a one test class so that you can observe deeper. If you have tests that fail, Fastlane returns an error and does not complete the process. According to my project, I have to check all my tests and develop them later.

As I edited the Fastfile with the following codes, I added the simulator models that I want to run my code. You can add devices, or remove them. Just remember what we edited on Fastfile:

lane :tests do
run_tests(workspace: “movieListing.xcworkspace”,
devices: [“iPhone 6s”, “iPhone 8”],
scheme: “movieListing — Prod”,
skip_build: true)
end

We should start with cleaning the terminal. Now just type: clear and press enter and type: fastlane and press enter again :)

I want to run ios tests so I will type 2 and press enter:

You can see the logs, I recommend you to read them and fix if you have issues. For example, here is one of my problem that I should fix them:

Do not worry if you see Exit status: 65 red line :) I did not remove my fail tests so I could not complete the process. Console logs shows the fail tests but does not show what is successfully tested.

So I will remove fail tests and show you the completed process. I can also see the simulators I chose is running the tests. Finally, I completed the process:

Well done, I briefly explained the basics of fastlane setup and configurations. I will search about Jenkins Integration and write my experiences :)

--

--

Burcu K. Kutluay
Mobile App Development Publication

IOS Developer / Architectural Design — App Management / Guitar Player