美文网首页Flutter学习
Fastline打包+发布蒲公英详解

Fastline打包+发布蒲公英详解

作者: StevenHu_Sir | 来源:发表于2019-07-20 22:44 被阅读0次

简介

是用Ruby语言编写的一套自动化工具集和框架,每一个工具实际都对应一个Ruby脚本,用来执行某一个特定的任务,而fastlane核心框架则允许使用者通过类似配置文件的形式,将不同的工具有机而灵活的结合在一起,从而形成一个个完整的自动化流程。比如我需要完成一套发布流程:

#发布到AppStore

lane :release do
  #增加build版本号,需要先配置build setting
  increment_build_number
  #pod资源更新
  cocoapods
  #打包
  gym
  #发布到AppStore
  deliver(force: true)
  #发布testflight测试
  testflight
end

准备工作

  • 首先确认是否安装了ruby,终端查看下ruby版本
> ruby -v
  • 确认是否安装了Xcode命令行工具
> xcode-select  --install

安装步骤

  • 如果用的是mac自带的ruby,需要 sudo权限
>  sudo gem install fastlane
  • 如果报错:ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/commander
> sudo gem install -n /usr/local/bin fastlane

初始化

在项目根目录下,初始化Fastlane

fastlane init//初始化配置文件,会在fastlane文件夹看到以下两个文件

Appfile //配置工程AppID和AppleID(开发者账号)
Fastfile //管理工程的lane的各个action,可以看成设置的任务流程

新版本安装的时候出现了下面的分支选择,按要求选择就行

1. 📸  Automate screenshots
2. 👩‍✈️  Automate beta distribution to TestFlight (自动testfilght型配置)
3. 🚀  Automate App Store distribution (自动发布型配置)
4. 🛠  Manual setup - manually setup your project to automate your (需要手动配置内容)

配置文件

  • Appfile: 存储有关开发者账号相关信息
  • Fastfile: 核心文件,主要用于 命令行调用和处理具体的流程,lane相对于一个方法或者函数
  • Deliverfile: deliver工具的配置文件
  • metadata: 元数据文件夹
  • Matchfile: Match操作对应的配置文件
  • screenshots: 截图文件夹

除开手动配置项,fastlane 会要求填写Apple ID,选择你的Team(如果有多个) 然后fastlane会自动检测当前目录下项目的App Name和App Identifier、Project。然后自行确认并按流程执行。

常用命令

  • fastlane actions: 展示所有有效action列表
  • fastlane action [action_name]: 展示一个action的详细说明,使用方法等
  • fastlane lanes: 展示fastfile中的所有lane
  • fastlane list: 展示fastfile中的所有的有效的lane
  • fastlane new_action: 创建一个新的action
  • fastlane env: 打印fastlane、ruby环境,一般提bug到issue的时候会要求提供

生命周期

生命周期

自动上传至fir或者蒲公英

  • 执行如下命令安装fir插件:
sudo fastlane add_plugin firim
  • 自动上传到fir还需执行如下命令:
sudo gem install -n /usr/local/bin fir-cli
  • 如果是蒲公英平台,安装如下插件:
fastlane add_plugin pgyer

报错如下

Plugin 'pgyer' was not properly loaded, make sure to follow the plugin docs

解决办法

sudo gem install -n /usr/local/bin bundler
bundle install
sudo fastlane -n /usr/local/bin add_plugin pgyer

实例

module Fastlane
  module Actions
    module SharedValues
      POD_INSTALL_CUSTOM_VALUE = :POD_INSTALL_CUSTOM_VALUE
    end
    class PodInstallAction < Action
      def self.run(params)
        repo = "-no-repo-update"
        command = []
        command << "pod install"
        if params[:repo_update]
          repo = "--repo-update"
        end
        command << repo
        if params[:verbose]
          command << "--verbose"
        end
        result = Actions.sh(command.join(' '))
        UI.success(command.join(' ') + " Successfully ")
        return result
      end

      def self.description
        "pod install action"
      end
      def self.details
        "verbose / repo-update"
      end
      def self.available_options
        [
        FastlaneCore::ConfigItem.new(key: :verbose,
                                       description: "Allow output detail in console",
                                       optional: true,
                                       is_string: false,
                                       default_value: false),
          FastlaneCore::ConfigItem.new(key: :repo_update,
                                       description: "Allow output detail in console",
                                       optional: true,
                                       is_string: false,
                                       default_value: false)
        ]
      end
      def self.output
      end
      def self.return_value
      end
      def self.authors
        ["yang"]
      end
      def self.is_supported?(platform)
        platform == :ios
      end
    end
  end
end

使用

  • 打开终端cd 到项目根目录执行以下代码
fastlane beta

打包成功标志

成功标志
Succeed~

补充

  • 如果Deliverfile、screenshots和metadata没有自动生成,通过deliver init 可以重新初始化
  • fastlane的配置会要求输入开发者账号密码,通过spaceship与Apple交互,并会产生一份有效期一个月的cookies文件:文件地址: ~/.fastlane/spaceship/[email]/cookie (两步验证问题)
  • Matchfile: match 这个action的配置文件,fastlane match init 自动生成,存放git地址等

相关文章

网友评论

    本文标题:Fastline打包+发布蒲公英详解

    本文链接:https://www.haomeiwen.com/subject/pisplctx.html