一、FastLane介绍

1.1 FastLane是什么?

FastLane是一种配置iOS和Android自动化Beta部署和发布的最简单的方法之一。它可以简化一些乏味、单调、重复的工作,像截图、代码签名以及发布App。

参考官方文档:https://docs.fastlane.tools/getting-started/ios/setup/

1.2 FastLane使用优势

省时:每次将新版本推送到商店或Beta测试服务时,都可节省时间。

集成:集成当前开发环境中所有存在的工具和服务。

开源:100%基于MIT许可开源。

简单:简单的设置助手,几分钟配置即可使用。

运行:基于你的app和数据,运行在本地机器上。

CI:集成几乎所有CI系统。

支持:支持iOS、Mac以及Android 应用。

自定义:根据自身需要扩展和定制fastlane,不依赖任何人。

命令行:不需要记住除fastlane以外的任何命令。

配置:可以在任何电脑上配置,包括CI服务器。

1.4 FastLane基础组件

实际上fastlane是一套工具集,包含如下工具:

1) 测试工具

scan:自动运行测试工具,可以生成漂亮的HTML报告

2) 生成证书、配置文件工具

cert:自动创建iOS代码签名证书(.cert文件)

sigh:自动创建、更新、下载、修复Provisioning Profile

pem:自动生成、更新推送配置文件

3) 截图、描设备边框

deliver:上传截图、元数据、App到iTunesConnect

snapshot:使用UI test功能实现自动截图

frameit:在截图的图片外层套上物理设备边框

4) 自动化编译工具

gym:自动化编译工具

5) App公测工具

pilot:管理TestFlight测试用户,上传二进制文件

firim:管理firim

1.5 FastLane基础环境

1) Fastlane其实是一个Ruby脚本的集合,首先查看是否安装Ruby

ruby -v

2) 检测:确保已安装最新Xcode命令行工具

xcode-select  --install

3) 安装:安装fastlane命令行

检查gem源: gem sources

必须添加此项:gem sources --add https://rubygems.org

安装fastlane:sudo gem install fastlane

4) 初始化:进入工程目录,初始化fastlane

fastlane init

在此过程中,fastlane将会自动检查你的工程项目,然后提示输入为输入信息及验证已输入信息是否正确。

5)给截图添加外框

初始化:fastlane frameit setup或者bundle exec fastlane frameit setup

安装依赖库:brew update && brew install imagemagick

1.7 FastLane主要文件说明

1) Fastfile:自动化执行配置文件

2) Appfile:存储App公共信息

3) Deliverfile:存储App发布信息

1.8 FastLane插件安装

1) 查看支持的所有插件:fastlane search_plugins

2) 安装插件:fastlane add_plugin [name]

3) 常用插件安装:

fastlane add_plugin versioning(设置App插件号车间)

fastlane add_plugin firim(设置测试版发布平台firim)

fastlane add_plugin pgyer (安装蒲公英)

二、FastLane抓图

2.1 FastLane自动抓图

snapshot使用UI Tests功能来抓取App上的图片。在开始使用UITests时,可以使用UI Test录制,只需按下Xcode底部的红色按钮。这是,xcode将会记录下你的操作代码。实际操作步骤如下:

1) 在xcode工程中创建一个新的UI测试目标。

2) 在工程目录下运行:fastlane snapshot init。

3) 将生成的./SnapshotHelper.swift文件添加到UI测试文件目录下。

4) 添加桥接头文件到我们的测试类中(只适用于OC代码)。

5) 在UI测试类中,按下录制按钮开始录制我们的交互操作。

6) 在UI测试类需要截图的地方添加代码:

Swift:snapshot(“01LoginScreen”);

OC:[Snapshotsnapshot:@”01LoginScreen” waitForLoadingIndicatore:YES];

7) 在setup()函数中添加如下代码:

swift:letapp = XCUIApplication()

setupSnapshot(app)

app.lanuch()

oc:XCUIAppication*app = [[XCUIApplication alloc] init];

[Snapshot setupSnapshot:app];

[app launch];

8) 在运行setup()函数过程中,将生成一个名为Snapfile的文件,这个文件在运行fastlane snapshot命令的时候将会被加载

2.3上传截图到App Store

使用fastlanesnapshot生成截图后,我们就开始上传图片到iTunes Connect。安装fastlane并且在工程根目录下运行snapshot init命令,我们会在工程根目录下看到fastlane/screenshots和fastlane/metadata目录。我们截取的图片就保存在fastlane/screenshots中。

上传截图很简单,只需要运行:

fastlane deliver

2.4使用Fastfile文件实现自动化

如果我们将上面的分步操作组合在一起执行,那么在开发团队中的任何人都可以上传新的截图,而通过对Fastfile文件的配置帮助我们实现了这一点,配置如下:

lane :screenshots do

snapshot

deliver

end

2.5为我们的截图加上物理设备边框

frameit将帮助我们为App截图构建漂亮的设备边框,只需要运行命令:

fastlane frameit

在此不在详述具体过程,效果如下(相当漂亮):

三、详细配置

3.1 Fastfile

default_platform(:ios)

platform :ios do
desc "Generate new localized screenshots"
lane :screenshots do
capture_screenshots
frame_screenshots(silver: true)
# upload_to_app_store
end
lane :tests do
run_tests(workspace: "xxx.xcworkspace",
devices: ["iPhone 6s"],
scheme: "xxxUITests")
end
lane :beta do
sigh(development: true)
# increment_build_number(xcodeproj: "xxx.xcodeproj")
# sync_code_signing(type: "appstore")
build_app(scheme: "xxx",
workspace: "xxx.xcworkspace",
include_bitcode: true,
export_method: "development")
pgyer(api_key: "xxxxxx", user_key: "xxxxxx")
# upload_to_testflight
end
end

3.2 Appfile

app_identifier("com.xxx") # The bundle identifier of your app
apple_id("xxx@xxx.com") # Your Apple email address itc_team_id("xxxxxx") # iTunes Connect Team ID
team_id("xxxxxx") # Developer Portal Team ID

3.3 Pluginfile

# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-pgyer'

3.4 Snapfile

# Uncomment the lines below you want to change by removing the # in the beginning

# A list of devices you want to take the screenshots from
devices([
"iPhone 8",
"iPhone 8 Plus",
"iPhone SE",
"iPhone X"
]) languages([
"zh-CHT",
# "en-US"
]) # The name of the scheme which contains the UI Tests
scheme("xxxUITests") # Where should the resulting screenshots be stored?
output_directory("./fastlane/screenshots") # remove the '#' to clear all previously generated screenshots before creating new ones
clear_previous_screenshots(true) # Arguments to pass to the app on launch. See https://docs.fastlane.tools/actions/snapshot/#launch-arguments
# launch_arguments(["-favColor red"]) # For more information about all available options run
# fastlane action snapshot

3.5 screenshots配置

screenshots/Framefile.json
{
"default": {
"keyword": {
"fonts": [
{
"font": "./fonts/Chinese.ttf",
"supported": ["zh-CHT"]
}
]
},
"title": {
"fonts": [
{
"font": "./fonts/Chinese.ttf",
"supported": ["zh-CHT"]
}
],
"color": "#545454"
},
"background": "./background.jpg",
"padding": 50,
"show_complete_frame": false,
"stack_title" : false,
"title_below_image": false
}, "data": [
{
"filter": "Health",
"keyword": {
"color": "#d21559"
}
},
{
"filter": "Medical",
"keyword": {
"color": "#feb909"
}
},
{
"filter": "Insurance",
"keyword": {
"color": "#aa4dbc"
}
},
{
"filter": "myCenter",
"keyword": {
"color": "#31bb48"
}
}
]
}

screenshots/zh-CHT/keyword.strings

"Health" = "健康";

"Medical" = "医疗";

"Insurance" = "保险";

"myCenter" = "我的";

screenshots/zh-CHT/title.strings

"Health" = "活动 & 自测";

"Medical" = "家庭医生 & 名医直达";

"Insurance" = "健康险 + 1对1服务";

"myCenter" = "订单、分期、保单等";

screenshots/fonts/Chinese.ttf

下载合适的字体文件并改名为Chinese.ttf

screenshots/background.jpg

iOS自动化打包发布(fastlane)的更多相关文章

  1. Mac Jenkins+fastlane 简单几步实现iOS自动化打包发布 + jenkins节点设置

    最近在使用jenkins 实现ios自动化打包发布蒲公英过程实践遇到了一些坑,特意记录下来方便有需要的人. 进入正题: 一.安装Jenkins 1.Mac上安装Jenkins 遇到到坑 因为 Jenk ...

  2. iOS 自动化打包发布(Fastlane+ Jenkins+蒲公英)

    安装 Xcode 命令行工具:xcode-select --install 安装 fastlane:sudo gem install fastlane --verbose 安装成功后查看版本:fast ...

  3. IOS自动化打包介绍

    IOS自动化打包介绍  标签: app打包 , Ios打包 , iphone打包 , iphone自动化打渠道包    分类:无线客户端技术, 贴吧技术 摘要 随着苹果手持设备用户的不断增加,ios应 ...

  4. iOS自动化打包上传的踩坑记

    http://www.cocoachina.com/ios/20160624/16811.html 很久以前就看了很多关于iOS自动打包ipa的文章, 看着感觉很简单, 但是因为一直没有AppleDe ...

  5. 【2】IOS APP打包发布

    目的: 本文的目的是对IOS APP打包发布做了对应的介绍,大家可根据文档步骤进行mac环境部署: 申请苹果开发者账号 此处略 创建申请证书 这样做的目的就是为你的电脑安装发布许可证,只有这样你的电脑 ...

  6. Jenkins+ Xcode+ 蒲公英 实现IOS自动化打包和分发

    Jenkins+ Xcode+ 蒲公英 实现IOS自动化打包和分发 直接入正题: Screen Shot 2015-09-18 at 16.56.20.png Mac上安装Jekins jekins下 ...

  7. iOS自动化打包 Jenkins+Gitlab+Fastlane+蒲公英+钉钉

    前言 这两天花时间整理一下自动化打包的整套流程,现在iOS端的整套流程是没有问题了,这个过程中踩得坑也的确是特别多,所以这周末把整个流程整理一下,总结出来这篇文章,希望能对有需要的小伙伴有点点帮助. ...

  8. iOS 自动化打包

    理想的情况:不打开工程的情况下,直接双击就能打包出一个IPA文件,这样就可以让测试直接使用 itools 进行安装. 分如下两种情况: 1)不依赖cocoapod  管理项目的自动化. 如果没有一个简 ...

  9. iOS企业版打包 发布在线安装包 plist

    本文转载至 http://blog.csdn.net/u011452278/article/details/49511385 原文转载:http://blog.csdn.net/pang040328/ ...

随机推荐

  1. windows 常用 命令

    Hyper-v管理               virtmgmt.msc 网络                         ncpa.cpl windows 远程登陆    mstsc.cpl C ...

  2. C语言中Extern用法

    extern用在变量或函数的声明前,用来说明“此变量/函数是在别处定义的,要在此处引用”. extern修饰变量的声明. 举例:若a.c中需引用b.c中的变量int v,可以在a.c中声明extern ...

  3. 计算机学院大学生程序设计竞赛(2015’12)The collector’s puzzle

    Problem Description There is a collector who own many valuable jewels. He has a problem about how to ...

  4. Experimental Educational Round: VolBIT Formulas Blitz C

    Description The numbers of all offices in the new building of the Tax Office of IT City will have lu ...

  5. Codeforces Round #339 (Div. 2) A

    Description Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which ...

  6. javscript---Bom 和Dom

    JavaScript分为 ECMAScript,DOM,BOM. ECMA javascript标准语法 BOM(Browser Object Model)是指浏览器对象模型,它使 JavaScrip ...

  7. 在Pycharm上编写WordCount程序

    本篇博客将给大家介绍怎么在PyCharm上编写运行WordCount程序. 第一步 下载安装PyCharm 下载Pycharm PyCharm的下载地址(Linux版本).下载完成后你将得到一个名叫: ...

  8. SecureCRT 遇到一个致命的错误且必须关闭

    1.将报错路径中VanDyke文件夹内的东西删除掉2.运行regedit,在注册表中将HKEY_LOCAL_MACHINA中SOFTWARE里的VanDyke删除3.注册表中打开HKEY_CURREN ...

  9. SQL---MySQL数据库---试炼

    1.需求 user表 temp表 user_temp_salary表 1.1 查找每个人在2018年前2个月的平均工资信息 SELECT b.`name` AS userName,c.name AS ...

  10. maya2012安装失败如何卸载重装

    AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...