fastlane
1.1、fastlane简介
是什么 ?:a command-line tool for iOS and Android developers to automate tedious tasks like generating screenshots, dealing with provisioning profiles, and releasing your application.
开发语言:Ruby
官方主页:https://fastlane.tools
源码仓库:https://github.com/fastlane/fastlane
1.2、安装fastlane

step1、通过HomeBrew安装

brew install fastlane

step2、配置PATH环境变量

export PATH=~/.fastlane/bin:$PATH
1.3、fastlane命令

fastlane命令的使用格式:

fastlane [global-option]...
fastlane [global-option]... <sub-command> [sub-command-option]...
fastlane [global-option]... <laneName>
1.3.1、fastlane -h | --help

查看fastlane命令的帮助信息。

1.3.2、fastlane -v | --version

查看fastlane的版本信息。

1.3.3、fastlane help <sub-command>

查看sub-command的使用帮助。

此命令等同于fastlane sub-command --help

1.3.4、fastlane init

在项目的根目录下,执行此命令,用来创建必要的配置信息。

上面的过程是交互的,在要求进行自动化的环境中不适合。

对于Apple ID,可以以-u APPLE_ID参数传入。

对于密码,以环境变量FASTLANE_PASSWORD的形式保存。

对于验证码,可以关闭验证码的二次验证。

此命令执行完毕后,会在项目根目录下生成一个文件夹,叫做fastlane,里面生成了两个Ruby语法的文件:AppfileFastfile

./fastlane/Appfile记录的是一些项目的元数据,其内容如下:

app_identifier "com.fpliu.newton" # The bundle identifier of your app
apple_id "792793182@qq.com" # Your Apple email address

team_id "NWLTN55N9S" # Developer Portal Team ID

# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Appfile.md

./fastlane/Fastfile就是类似于其他构建工具的核心配置文件,这是我们频繁修改的文件,其内容如下:

# Customise this file, documentation can be found here:
# https://docs.fastlane.tools/actions/
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.61.0"

default_platform :ios

platform :ios do
  before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    cocoapods
    # carthage
  end

  desc "Runs all the tests"
  lane :test do
    scan
  end

  desc "Submit a new Beta Build to Apple TestFlight"
  desc "This will also make sure the profile is up to date"
  lane :beta do
    # match(type: "appstore") # more information: https://codesigning.guide
    gym # Build your app - more options available
    pilot

    # sh "your_script.sh"
    # You can also use other beta testing services here (run `fastlane actions`)
  end

  desc "Deploy a new version to the App Store"
  lane :release do
    # match(type: "appstore")
    # snapshot
    gym # Build your app - more options available
    deliver(force: true)
    # frameit
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end

  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end

# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used. No personal data is recorded.
# Learn more at https://github.com/fastlane/fastlane#metrics

这里面定义了一些lanelane就相当于Antgradle等构建工具中的任务的概念。

这些lane可以通过fastlane命令直接执行,形如:fastlane lane

1.3.5、fastlane lanes

显示该工程中的所有lane,包含每个lane的详细描述。

这些lane定义在./fastlane/Fastfile中。

1.3.6、fastlane list

显示该工程中的所有lane,不包含每个lane的详细描述。

这些lane定义在./fastlane/Fastfile中。

1.3.7、fastlane actions

显示支持的所有的action。目前大约有200来个。

1.3.8、fastlane action actionName

显示指定的action的详细帮助信息。

1.3.9、fastlane run actionName key1:value1 key2:value2

直接运行指定的action,而不需要通过定义lane

1.3.10、fastlane env

打印环境信息。当您出现问题的时候,想要在GitHub上提交您的环境信息,使用此命令即可, 他会把这些信息自动复制到剪贴板,您只需要把这些信息粘贴上去即可。