Continuous Integration and Continuous Delivery With Fastlane for Native and ReactNative iOS apps

Neha Sharma
codewave technologies
4 min readMay 21, 2019

--

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.

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 RubyGemssudo gem install fastlane -NV# Alternatively using Homebrewbrew cask install fastlane

Setup fastlane in project directory

fastlane init

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

fastlane folder with Appfile & Fastfile

Appfile: It 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 appapple_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 teamsteam_name "Neha"team_id "A1B2C3D4"# To select a team for App Store Connect useitc_team_name "Company Name"itc_team_id "12345678"

Fastfile: It contains automation configuration that can be run with fastlane.

Here are process which we do for beta or App store realese

lane :beta do increment_build_number build_app upload_to_testflightendlane :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 discussion below!

Please share and give some claps so others can also find it useful 👏👏👏👏👏👏 !!!!

Follow me on: Facebook | Twitter | GitHub | LinkedIn

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.

--

--

Neha Sharma
codewave technologies

Sr. iOS Developer & Free Time Blogger. I am both driven and self-motivated and constantly experimenting with new technologies and techniques.