Manage iOS Versioning for Release with Fastlane

Didik Maulana Ardiansyah
Gravel Product & Tech
4 min readAug 22, 2023
Photo by Ankush Minda on Unsplash

As the world of mobile app development continues to evolve at a rapid pace, staying ahead of the curve and streamlining your processes becomes crucial. One essential aspect of mobile app development is versioning, particularly for iOS apps. Proper versioning not only helps users understand the updates and changes in your app but also enables your development team to maintain a clear and organized release process.

Enter “Fastlane”, a powerful and versatile tool that can significantly simplify your iOS app development workflow, including version management. In this article, we’ll explore how to leverage Fastlane to manage iOS versioning for release, making the process smoother and more efficient.

Why is Versioning Important?

Versioning is a critical part of the software release cycle, providing clarity, and transparency to users and stakeholders about the changes and improvements in each release. A well-defined versioning strategy helps users understand what to expect from an update and assists your support team in troubleshooting issues. Furthermore, consistent versioning enables you to track the evolution of your app over time and makes it easier to analyze user feedback.

What is Fastlane?

Fastlane is an open-source platform that automates the building and releasing of mobile apps. It was designed to simplify the various tasks involved in app development, such as building, testing, and distributing the app to the App Store. Fastlane supports both iOS and Android app development, making it a valuable asset for cross-platform teams.

How Fastlane Simplifies Versioning

Fastlane offers a variety of tools, known as “actions”, that automate common tasks in the app deployment process. When it comes to versioning, Fastlane provides actions that allow you to set the version number and build number of your iOS app effortlessly. Here’s a step-by-step guide to using Fastlane for version management:

Set Up Fastlane

Before you can use Fastlane, you need to install it in your project. You can install Fastlane using RubyGems and it’s recommended to do this within your project’s directory.

gem install fastlane -NV

Initialize Fastlane

🚀 Navigate to your project directory in the terminal and run the following command to initialize Fastlane for your project:

cd /your_project_directory
fastlane init

🚀 Choose Manual setup.

Fastlane configuration setup

🚀 Continue until successfully generated fastlane configuration.

Successfully generated Fastlane files

Add Fastlane Versioning Plugin

The Fastlane versioning plugin allows you to set or get versions without using agvtool and do some small tricks.

Navigate to your project directory in the terminal and run the following command:

fastlane add_plugin versioning

Define Versioning Configuration

Fastlane uses a configuration file called “Fastfile” to define various tasks for your project. You’ll need to set up your versioning configuration in this file. Open Fastfile and this is an example:

platform :ios do
desc "Automatic update the version number and create release branch"
lane :update_version do
# Show option update type
update_type = UI.select("Select update type: ", ["major", "minor", "patch"])

# Checkout to the master branch
sh("git checkout master")

# Pull the master branch to make sure always updated
sh("git pull origin master")

# Increment the version number by update_type
new_version = increment_version_number(bump_type: update_type)

# Create a new release branch and checkout
sh("git checkout -b release/#{new_version}")

# Add changes
sh("git add --all")

# Commit changes
sh("git commit -m 'Update the app version to #{new_version}'")

# Push release branch to origin
sh("git push origin release/#{new_version}")

UI.success("Successfully updated app version to #{new_version}")
end
end

Run Fastlane

To update the version and build numbers, run the Fastlane lane you defined:

bundle exec fastlane update_version

This command executes the “update_version” lane in your Fastfile, incrementing the version(also build numbers) in your XCode project, and automatically creating a release branch to your git repository.

Update the version number with Fastlane

Benefits of Using Fastlane for Versioning

Using Fastlane for iOS versioning offers several benefits:

  • Automation: Fastlane automates the versioning process, reducing the risk of human error, and ensuring consistency across releases.
  • Efficiency: With Fastlane, you can quickly update the version and build numbers version time for your development team.
  • Clear Documentation: Fastlane’s actions are well documented, easy to follow, and maintain your versioning process.
  • Customization: Fastlane allows you to tailor your versioning workflow to fit your specific requirements.
  • Collaboration: Fastlane simplifies collaboration among team members by providing standard members to manage versioning.

Conclusion

Managing iOS versioning for release is a crucial aspect of mobile app development. Fastlane simplifies this process by providing automation, consistency, and flexibility. By embracing Fastlane into your workflow, you can ensure a smoother and more efficient release cycle, leading to a better user experience and a more organized development process. So, dive into the world of Fastlane, streamline your versioning, and focus on building iOS apps.

--

--