Liam SY Kim
by Liam SY Kim
3 min read

Categories

There are many things to consider for reducing deployment time.

Fastlane is useful for resolving the issuse.

Fastlane is Ruby based automatic build opensource library.

For your iOS project, they support code signing, screenshot for app store connect, uploading testflight, uploading app store automatically.

I will just explain and work for full process of automatic uploading testflight.

Install fastlane

On your commandline, type the line like as below.

# Use RubyGems 
sudo gem install fastlane -NV 

# Use Homebrew  
brew cask install fastlane

Fastlane initial setting for your project

This is the process to generate lanes at first.

Type fastlane init on your commantline.

You can see the results.

[✔] 🚀 
[✔] Looking for iOS and Android projects in current directory...
[18:55:36]: Created new folder './fastlane'.
[18:55:36]: Detected an iOS/macOS project in the current directory: 'GitToday.xcworkspace'
[18:55:36]: -----------------------------
[18:55:36]: --- Welcome to fastlane 🚀 ---
[18:55:36]: -----------------------------
[18:55:36]: fastlane can help you with all kinds of automation for your mobile app
[18:55:36]: We recommend automating one task first, and then gradually automating more over time
[18:55:36]: What would you like to use fastlane for?
1. 📸  Automate screenshots
2. 👩‍✈️  Automate beta distribution to TestFlight
3. 🚀  Automate App Store distribution
4. 🛠  Manual setup - manually setup your project to automate your tasks
?  


For now, I will upload my app to testflight.

Choosed number 2.

Then, Fastlane asks Apple ID for accessing App Store Connect.

Enter your apple ID which is registered on App Store Connect.

[18:56:39]: --------------------------------
[18:56:39]: --- Login with your Apple ID ---
[18:56:39]: --------------------------------
[18:56:39]: To use App Store Connect and Apple Developer Portal features as part of fastlane,
[18:56:39]: we will ask you for your Apple ID username and password
[18:56:39]: This is necessary for certain fastlane features, for example:
[18:56:39]: 
[18:56:39]: - Create and manage your provisioning profiles on the Developer Portal
[18:56:39]: - Upload and manage TestFlight and App Store builds on App Store Connect
[18:56:39]: - Manage your App Store Connect app metadata and screenshots
[18:56:39]: 
[18:56:39]: Your Apple ID credentials will only be stored in your Keychain, on your local machine
[18:56:39]: For more information, check out
[18:56:39]: 	https://github.com/fastlane/fastlane/tree/master/credentials_manager
[18:56:39]: 
[18:56:39]: Please enter your Apple ID developer credentials
[18:56:39]: Apple ID Username:

Choose your team for deployment.

Available session is not valid any more. Continuing with normal login.
Multiple App Store Connect teams found, please enter the number of the team you want to use: 
1) "FitPet Co.,Ltd." (118839470)
2) "Prography Inc." (120757688)
3) "Sooyong Kim" (121169581)
3
Multiple teams found on the Developer Portal, please enter the number of the team you want to use: 
1) 6B2VQKE4D7 "FitPet Co.,Ltd." (Company/Organization)
2) MSW35G2APL "Prography Inc." (Company/Organization)
3) X7AF2T5392 "Sooyong Kim" (Individual)
3

It is the whole process for initializing fastlane folder at first.

From now on, you can upload your app to testflight by typing a command line fastlane beta!

Understanding lane

Fastline init makes your app to upload testflight & appstore easy.

However, what if you want to custom own command?

Fastlane supports lane for custom command excuting units.

These are defined on fastfile in fastlane folder

  • Appfile: Restore app identifier, Apple ID.
  • Fastfile: Manages lanes for asking specific actions.
default_platform(:ios)

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do
    increment_build_number(xcodeproj: "GitToday.xcodeproj")
    build_app(workspace: "GitToday.xcworkspace", scheme: "GitToday")
    upload_to_testflight
  end
end

platform shows you what platform do this command supports.

In iOS platform, there could be many lanes.

Above code is the lane produced from Fastlane init It is serial units for fastlane beta.

Each lane is each fastlane commands.

Add Options for lane.

You can pass parameters from the command line to your lane.

From fastlane docs , use the following syntax.

fastlane [lane] key:value key2:value2

fastlane deploy submit:false build_number:24

and you can also excute command of lane in lane like as following definition.

lane :deploy do |options|
  # ...
  build(release: true) # that's the important bit
  hockey
  # ...
end


lane :build do |options|
  scheme = (options[:release] ? "Release" : "Staging")
  build_ios_app(scheme: scheme)
end

These Options what I introduced are very useful. Also, there are many other options for customizing your lanes.

If you want to know more options, check from fastlane docs