fastlane自动化打包

1.简介

Fastlane是一套使用Ruby写的自动化工具集,用于iOS和Android的自动化打包、发布等工作,可以节省大量的时间。

fastlane.png

Github:https://github.com/fastlane/fastlane
官网:https://fastlane.tools/
文档:https://docs.fastlane.tools


2.安装环境配置

RVM

RVM全名Ruby Version Manager (RVM) 是国外一个开源的ruby版本管理工具
附上官网:www.rvm.io
- RVM安装

curl -L get.rvm.io | bash -s stable
  • 检查RVM安装版本
ruby -v
  • 载入 RVM 环境(新开 Termal 就不用这么做了,会自动重新载入的)
source ~/.rvm/scripts/rvm

ruby.png

Ruby一种简单快捷的面向对象(面向对象程序设计)脚本语言,在20世纪90年代由日本人松本行弘(Yukihiro Matsumoto)开发,遵守GPL协议和Ruby License。

  • 用RVM安装Ruby(默认安装最新版本)
rvm install ruby

fastlane_text.png

  • 安装xcode-select -> 选择安装
xcode-select --install

3.firim创建与编写

项目配置 fastlane

cd 项目根目录
fastlane init
  • 期间会让你输入 Apple ID 账号密码(这个信息会存在钥匙串中,后续使用无需再输入密码)
  • 会检测当前的 app identifier 是否在 ADC 中
  • 会检测当前 app 是否在 ITC 中

如果已经在 ADC 和 ITC 中创建相应的信息,那么过程会很顺利,如下图:
fastlaneInit.png

fastlane文件夹 生成项目配置

fastlaneFile.png

打开Fastfile文件
# 定义fastlane版本号
fastlane_version "2.66.2"
# 定义打包平台
default_platform :ios
# 任务脚本
platform :ios do
# *********************创建firim版本打包*********************
lane :firim do
build_number = get_build_number(xcodeproj: "Characters.xcodeproj")
version      = get_version_number(xcodeproj: "Characters.xcodeproj")
# 开始打包
gym(
# ********************* 开始打包 *********************
    scheme: "项目名",
    workspace: "项目名.xcworkspace",
    silent: true,
    include_symbols: true,              # 是否生成符号表,默认true
    include_bitcode: true,              # 是否开启bitcode,默认true
    clean:true,                         # 是否清空以前的编译信息 true:是
    configuration:"Release",           # 指定打包方式,Release 或者 Debug
    export_method:"development",       # 指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development
    output_name:"输出文件名",            # 输出文件名
    output_directory:"./fastlane/bulid",# 指定输出文件夹
# ********************* 打包完成 *********************
)
# 使用fir-cli上传ipa
# IOMAT你项目要打包的名称
# 请将-T后的数字更改为在fir申请的APIToken
firim(firim_api_token: "申请的APIToken")
end
end

4.上传APPStore

# 定义fastlane版本号
fastlane_version "2.66.2"
# 定义打包平台
default_platform :ios
# 任务脚本
platform :ios do

lane :appStore do
build_number = get_build_number(xcodeproj: "项目名.xcodeproj")
version      = get_version_number(xcodeproj: "项目名.xcodeproj")
# 指定输出目录
gym(
    configuration:"Release",           # 指定打包方式,Release 或者 Debug
    export_method:"app-store",       # 指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development
    output_name:"输出文件名",               # 输出文件名
    output_directory: './build',
)
# 上传所有信息到App Store
deliver(force: true)
end
end

猜你喜欢

转载自blog.csdn.net/ios_qing/article/details/78647549