CI-CD with fastlane

CI/CD With Fastlane for Native and React Native iOS apps

Fastlane provides easiest way to automate & deploy your iOS and Android mobile apps. It helps to generate screenshots, build, test and deploy

CI and CD are very popular words when we talk about modern development practises.

CI stands for Continuous Integration, it is engineering practise of frequently integrating isolated changes to a large code & test them simultaneously.

CD means Continuous Development or Continuous Delivery in which build software is always in a state of production or deploy.

Benefit of Continuous Integration/ Continuous Development/ Continuous Delivery

  • Less bugs are passed to production as mostly are captured during automated testing.
  • Generating a build is easy than earlier.
  • Developer will get to know about any bug in building stage & can work on fixing then before moving it to another stage.
  • QA team will get more time to improve the product quality instead of only testing the product.
  • It is easy to make small changes & encourage team to finish it fast.
  • Released builds are less risky & can be easily fixed.
  • Customer can notice continuous improvement & quality of product on everyday basis.
ci_cd_continuous_integration_continuous_delivery_fastlane_react_native_continuous_deployment_app_devops_app_store_automation

Implement CI/CD in iOS using Fastlane

Fastlane provides easiest way to automate & deploy your iOS and Android mobile apps. It helps you to generate screenshots, build , test and deploy app on App Store.

Install fastlane


# Using RubyGems
sudo gem install fastlane -NV 
# Alternatively using Homebrew 
brew cask install fastlane

Setup Fastlane in project directory

fastlane init

This command will create 2 text file in your project: Appfile & Fastfile

fastlane_react_native_ci_cd_for_ios_apps_using_fastlane_continuous_integration_continuos_delivery_continuous_deployment_ios_react_native_fastlane

AppfileIt store very important information which are used by fastlane tool like Bundle In, Apple ID, iTunes Connect Team Id, Developer Team Id to build & deploy your app to App store or in TestFlight.

app_identifier "neha.fastlaneExample" 
#The bundle identifier of your app
apple_id "neha@gmail.com"
# Your Apple email address
# You can uncomment the lines below and add your own
# team selection in case you're in multiple teams
team_name "Neha"
team_id "A1B2C3D4"
# To select a team for App Store Connect use
itc_team_name "Company Name"
itc_team_id "12345678"

FastfileIt contains automation configuration that can be run with fastlane.

Here are process which we do for beta or App store release-

lane :beta do
 increment_build_number
 build_app
 upload_to_testflight
end
lane :release do
 capture_screenshots
 build_app
 upload_to_app_store       
end

We have define 2 lanes for beta & app store release.

In terminal, inside your project root directory. Run this command to release your build on iTune connects.

fastlane release   #release is the lane which we created in fastfile

Inside Lanes we define actions which we want to perform. If any step fails in lane then process will stop there.

In beta lane, we are increasing the build number, building IPA file and uploading to test flight.

In release lane, we are generating screenshots, building IPA file and uploading to iTune Connects.

Generating Provisioning Profile & Code Signing Certificate

Now, I will create a new lane named codeSign.

produce: This command will create App ID on developer accounts & App Account on iTune Connects.

cert: It will generate iPhone Developer & Distribution certificate for your app.

sigh: It will generate provisioning profile for app store.

lane :codeSign do
 produce
 cert( 
 username: "neha@gmail.com"
 )
 sigh(
 force: true
 )
end

If you already have metadata & screenshots on iTune Connect then run this command on terminal to get the same.

fastlane deliver init -username neha@gmail.com --team_id 12345678

deliver: This will help you to update your existing metadata & screenshots on iTune Connects.

fastlane deliver

Why fastlane?

fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. It handles all tedious tasks, like

  • Generating screenshots & metadata
  • Dealing with code signing & provisioning profile
  • Build your app
  • Releasing your application

Advantage of Using Fastlane

  • Save hours every time you push a new release to the store or beta testing service
  • Supports iOS, Mac, and Android apps
  • 100% open source
  • Easy setup assistant to get started in a few minutes
  • Never remember any commands any more, just fastlane
  • Extend and customise fastlane to fit your needs, you’re not dependent on anyone

Recommended References-

https://docs.fastlane.tools/

I hope you enjoyed this CI/CD with fastlane tutorial, and I look forward to seeing how you use fastlane in your deployment pipeline. If you have any questions or comments, please share in the discussion below!

Stay connected to Codewave for more such insights and feel free to reach us at hello@codewave.in or +91 8971824910. If comfortable you may drop by at 1st Floor, Shree Chambers, #307, Outer Ring Rd, Banashankari 3rd Stage, Bengaluru, Karnataka 560085. Thanks for taking out time to read this article. We hope it enriched your existing knowledge. Do let us know your views, by sending an email to hello@codewave.in.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Prev
What does it mean to be a digital first business?
Next
Celebrating People & Authenticity: Codewave’s authenticity anthem
Celebrating People & Authenticity: Codewave’s authenticity anthem

Celebrating People & Authenticity: Codewave’s authenticity anthem

Our authenticity anthem magic happens, when you accept who you are

Subscribe to Codewave Insights