Fastlane là công cụ hỗ trợ tự động build, screenshot, upload app, notify slack... chỉ với vài config.
- Cài đặt
 
brew cask install fastlane
- Vào thư mục source code để setup fastlane (giống cocoapods)
 
fastlane init
- Fastlane sẽ tạo ra file 
fastlane/Fastfile, thực hiện sửa fastfile 
vi fastlane/Fastfile
thay nội dung như sau
# 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 "Generate ipa"
  lane :generate_ipa_develop do
    enable_automatic_code_signing
    increment_build_number
    build_ios_app(
      configuration: "Debug",
      scheme: "App_Develop",
      clean: true,
      export_method: 'development',
      output_directory: "~/Desktop/app-ipa", # Destination directory. Defaults to current directory.
      output_name: "AppName.ipa",
    )
    deploygate(
        api_token: "--api-token-lay-tu-deploygate--",
        user: "deploygate username",
        ipa: "~/Desktop/app-ipa/AppName.ipa",
        message: "Build #{lane_context[SharedValues::BUILD_NUMBER]}",
        distribution_key: "(Optional) Target Distribution Key",
        distribution_name: "(Optional) Target Distribution Name"
    )
  end
end
Trong đó
- Phần # : comment, sẽ không được chạy
 - Lane 
:generate_ipa_develop: một lane là một tập các hành động được thực thi từ trên xuống dưới ghi fastlane chạy - Lane trên thực hiện 4 việc: mở automatic-code-sign, tăng số build number, thực hiện build app với scheme 
APP_DEVELOP(mỗi ứng dụng ios có nhiều scheme, xem bước 4 để tạo) lưu vào~/DEVELOP/APP-IPA/APPNAME.IPA, upload lên deploygate vớiapi_tokenvà user đã được tạo ở deploygatehttps://deploygate.com/settings.
File ipa nguồn thì đã được gen ở stepbuild_ios_app.
Lưu lại fastfile 
esc
:wq
- Tạo scheme
Mở Xcode, chọn project, ở góc trên bên trái, ở bên phải nútStopcó tên scheme, nhấp vào chọnNew Scheme..., sau đó nhập nameApp_Developđã điền vào ởFastfile - Cài đặt Certificate và Provisioning từ trang develop (làm manual, sẽ có hướng dẫn làm automatic với fastlane)
 - Chạy thử và đợi
 
fastlane generate_ipa_develop
Sau đó kiểm tra trên Deploygate để chắc chắn fastlane chạy hoàn thành
7. Commit và push source code (bao gồm cả thư mục fastlane) vào nhánh ở remote : develop hoặc nhánh riêng nếu cần thiết.
Done - Bài tiếp sẽ hướng dẫn config Jenkins và tự chạy fastlane