Fastlane一键自动化打包发布 iOS 项目

2019-01-28  本文已影响8人  轮子糙

一、Fastlane简介

Fastlane 是一个完全开源的项目,是一款为 iOS 和 Android 开发者提供的自动化构建工具,它可以帮助开发者将 App 打包、签名、测试、发布、信息整理、提交 App Store 等工作完整的连接起来,实现完全自动化的工作流。

GitHub 地址

二、Fastlane 安装

// 查看 Ruby 版本
ruby -v
// 查看 gem 的source
gem sources
xcode-select --install
sudo gem install fastlane --verbose
sudo gem install -n /usr/local/bin fastlane
fastlane --version

三、初始化 Fastlane 配置

fastlane add_plugin pgyer
fastlane init
fastlane_version "2.101.1"

default_platform :ios

platform :ios do

  desc "以 development 方式打包并上传到蒲公英"
  lane :test_beta do

    puts "以 development 方式打包"
    gym(
      # 指定打包所使用的输出方式 (可选: app-store, package, ad-hoc, enterprise, development)
      export_method: "development",
      # 指定项目的 scheme 名称
      scheme: "xxx",
      # 指定输出的文件夹地址
      output_directory: "./archive/test_beta/" + Time.new.strftime("%Y-%m-%d-%H:%M:%S"),
    )

    puts "上传 ipa 包到蒲公英"
    pgyer(
      # 蒲公英 API KEY
      api_key: "xxx",
      # 蒲公英 USER KEY
      user_key: "xxx"
    )

  end

  desc "以 ad-hoc 方式打包并上传到蒲公英"
  lane :beta do
    puts "自动生成 Provisioning Profiles 文件"
    sigh(
      # 指定输出的文件夹地址
      output_path: "./archive/sign",
      # 是否为 AdHoc 证书(设为 false 或不写默认为 AppStore 证书)
      adhoc: true
    )

    puts "以 ad-hoc 方式打包"
    gym(
      # 指定打包所使用的输出方式 (可选: app-store, package, ad-hoc, enterprise, development)
      export_method: "ad-hoc",
      # 指定项目的 scheme 名称
      scheme: "xxx",
      # 指定输出的文件夹地址
      output_directory: "./archive/beta/" + Time.new.strftime("%Y-%m-%d-%H:%M:%S"),
      # 指定打包方式 (可选: Release, Debug)
      configuration: "Release"
    )
    puts "上传 ipa 包到蒲公英"
    pgyer(
      # 蒲公英 API KEY
      api_key: "xxx",
      # 蒲公英 USER KEY
      user_key: "xxx"
    )

  end

  desc "以 app-store 方式打包并上传到 iTunes Connect"
  lane :release do

    puts "自动生成 Provisioning Profiles 文件"
    sigh(
      # 指定输出的文件夹地址
      output_path: "./archive/sign"
    )

    puts "以 app-store 方式打包"
    gym(
      # 指定打包所使用的输出方式 (可选: app-store, package, ad-hoc, enterprise, development)
      export_method: "app-store",
      # 指定项目的 scheme 名称
      scheme: "xxx",
      # 指定输出的文件夹地址
      output_directory: "./archive/release/" + Time.new.strftime("%Y-%m-%d-%H:%M:%S"),
      # 指定打包方式 (可选: Release, Debug)
      configuration: "Release"
    )

    puts "上传 ipa 包到 iTunes Connect"
    deliver(
      # 跳过截图上传
      skip_screenshots: true,
      # 跳过元数据上传
      skip_metadata: true,
      # 跳过审核直接上传
      force: true
    )

  end

end

四、使用Fastlane一键打包

fastlane test_beta
fastlane release

参考
Fastlane官方教程
Fastlane带来的全自动化发布

********将来的你一定会感激现在拼命的自己,愿每一个努力的人都能有收获!********
| 简书主页 | CSDN博客 |

上一篇 下一篇

猜你喜欢

热点阅读