简介

Fastlane是一套使用Ruby写的自动化工具集,用于iOS和Android的自动化打包、发布等工作,可以节省大量的时间。
Github:https://github.com/fastlane/fastlane
官网:https://fastlane.tools/
文档:https://docs.fastlane.tools/
安装
1、首先要安装正确的 Ruby 版本。在终端窗口中用下列命令来确认:
ruby -v
2、然后检查 Xcode 命令行工具是否安装。在终端窗口中输入命令:
xcode-select --install
如果未安装,终端会开始安装,如果报错误:command line tools are already installed, use "Software Update" to install updates.代表已经安装。
3、以上依赖配置好之后就可以通过 rubygem 进行安装了:
$ sudo gem install fastlane
安心等待一会,fastlane就安装完成了。
初始化
打开终端,cd到你的工程目录,然后执行fastlane init:
$ cd to/your/ios/project $ fastlane init [14:21:43]: Detected iOS/Mac project in current directory... [14:21:43]: This setup will help you get up and running in no time. [14:21:43]: fastlane will check what tools you're already using and set up [14:21:43]: the tool automatically for you. Have fun! [14:21:43]: Created new folder './fastlane'. [14:21:43]: $ xcodebuild -showBuildSettings -project ./xxx.xcodeproj [14:21:48]: Your Apple ID (e.g. fastlane@krausefx.com): xxx@xxx.xom [14:21:54]: Verifying that app is available on the Apple Developer Portal and iTunes Connect... [14:21:54]: Starting login with user 'xxx@xxx.com' +----------------+--------------------------------------+ | Detected Values | +----------------+--------------------------------------+ | Apple ID | xxx@xxx.com | | App Name | xxx | | App Identifier | com.xxx.xxx | | Project | /Users/lisong/Desktop/xxx/x | | | xx.xcodeproj | +----------------+--------------------------------------+ [14:22:06]: Please confirm the above values (y/n) y [14:22:09]: Created new file './fastlane/Appfile'. Edit it to manage your preferred app metadata information. [14:22:09]: Loading up 'deliver', this might take a few seconds [14:22:09]: Login to iTunes Connect (xxx@xxx.com) [14:22:13]: Login successful +-----------------------+------------------------+ | deliver 2.30.1 Summary | +-----------------------+------------------------+ | screenshots_path | ./fastlane/screenshots | | metadata_path | ./fastlane/metadata | | username | xxx@xxx.com | | app_identifier | com.xxx.xxx | | edit_live | false | | platform | ios | | skip_binary_upload | false | | skip_screenshots | false | | skip_metadata | false | | force | false | | submit_for_review | false | | automatic_release | false | | dev_portal_team_id | WKR87TTKML | | overwrite_screenshots | false | +-----------------------+------------------------+ [14:22:21]: Writing to 'fastlane/metadata/zh-Hans/description.txt' ... [14:22:21]: Writing to 'fastlane/metadata/review_information/notes.txt' [14:22:21]: Successfully created new configuration files. [14:22:22]: Successfully downloaded large app icon [14:22:22]: Downloading all existing screenshots... [14:22:27]: Downloading existing screenshot '1_iphone4_1.1.jpg' for language 'zh-Hans' ··· [14:22:34]: Downloading existing screenshot '5_iphone6_5.5.jpg' for language 'zh-Hans' [14:22:34]: Successfully downloaded all existing screenshots [14:22:34]: Successfully created new Deliverfile at path 'fastlane/Deliverfile' [14:22:34]: $ xcodebuild -list -project ./xxx.xcodeproj [14:22:35]: 'snapshot' not enabled. [14:22:35]: 'cocoapods' enabled. [14:22:35]: 'carthage' not enabled. [14:22:35]: Created new file './fastlane/Fastfile'. Edit it to manage your own deployment lanes. [14:22:35]: fastlane will collect the number of errors for each action to detect integration issues [14:22:35]: No sensitive/private information will be uploaded [14:22:35]: Learn more at https://github.com/fastlane/fastlane#metrics [14:22:35]: Successfully finished setting up fastlane
在 “Your Apple ID” 这一步输入苹果开发者账号。在“Please confirm the above values”这一步,确认信息,没问题输入 y。然后,fastlane 会进行一系列的初始化操作,包括下载 App Store 上的元数据和截屏文件。
等待初始化完成之后,工程目录下就多了一个 fastlane目录,其内容如下:
咱们来看两个主要的,Appfile和Fastfile。
Appfile
Appfile用来存放app_identifier,apple_id和team_id。 了解详情,它的格式是这样的:
app_identifier "com.xxx.xxx" # app的bundle identifier apple_id "xxx@xxx.com" # 你的Apple ID team_id "XXXXXXXXXX" # Team ID
你也可以为每个lane(后面会讲到)提供不同的 app_identifier, apple_id 和 team_id,例如:
app_identifier "com.aaa.aaa" apple_id "aaa@aaa.com" team_id "AAAAAAAAAA" for_lane :inhouse do app_identifier "com.bbb.bbb" apple_id "bbb@bbb.com" team_id "AAAAAAAAAA" end
这里就是为Fastfile中定义的:inhouse设置单独的信息。
Fastfile
Fastfile管理你所创建的 lane ,了解详情。它的格式是这样的:
··· # 自动更新fastlane 工具 # update_fastlane #需要的fastlane的最小版本,在每次执行之后会检查是否有新版本,如果有会在最后末尾追加新版本提醒 fastlane_version "2.30.1" #默认使用平台是 ios,也就是说文件可以定义多个平台 default_platform :ios platform :ios do before_all do # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..." cocoapods end desc "Runs all the tests" lane :test do scan end desc "提交一个新的Beta版本到 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(scheme: "Docment") # Build your app - more options available pilot # sh "your_script.sh" end desc "部署一个新版本到App Store" lane :release do # match(type: "appstore") # snapshot gym(scheme: "Docment") # Build your app - more options available deliver(force: true) # frameit end # 你可以定义自己的lane #执行lane成功后的回调 after_all do |lane| # slack( # message: "Successfully deployed new App Update." # ) end # 如果流程发生异常会走这里并终止 error do |lane, exception| # slack( # message: exception.message, # success: false # ) end end 我们也可以定义一个自己的lane: desc "企业版" lane :inHouse do gym(scheme: "XXX", export_method:"enterprise", output_directory "./build", # 打包后的 ipa 文件存放的目录 output_name "XXX" # ipa 文件名 ) end
其中一个lane就是一个任务,里面是一个个的action组成的工作流。
利用目前支持的工具可以做所有包含自动化和可持续化构建的每个环节,例如:
scan 自动化测试工具,很好的封装了 Unit Test
sigh 针对于 iOS 项目开发证书和 Provision file 的下载工具
match 同步团队每个人的证书和 Provision file 的超赞工具
gym 针对于 iOS 编译打包生成 ipa 文件
deliver 用于上传应用的二进制代码,应用截屏和元数据到 App Store
snapshot 可以自动化iOS应用在每个设备上的本地化截屏过程
执行
定义完lane之后怎么执行呢?打开终端,切换到项目的根目录:执行fastlane lane'name就可以了。成功之后会在相应的路径下生成ipa文件,如果报错的话就根据错误信息好好查看文档。
其他
1、这里是官方提供的一些例子。
2、想了解fastlane命令的话可以执行$ fastlane –help
3、查看可用任务的列表,可以执行命令$ fastlane lanes
4、fastlane也提供了很多插件方便我们使用,例如pgyer(发布app到蒲公英)。我们也可以打完包直接传到蒲公英上,具体的可以看蒲公英提供的文档。
如果你感觉有些插件不符合自己的情况,你甚至可以自定义插件
5、多个 lane 的话实际上是可以相互调用的,这个其实特别实用。例如:
default_platform :ios platform :ios do lane :prepare do cocoapods match end desc 'fastlane build' 'fastlane build type:adhoc' lane :build do |options| # 调用上面的 prepare 任务 prepare case options[:type] when 'adhoc' adhoc else appstore end end lane : adhoc do ··· end lane : appstore do ··· end end
我们可以在 Fastfile 文件中添加一个函数来设置version号和build号。
default_platform :ios
def prepare_version(options)
increment_version_number(
version_number: options[:version]
)
increment_build_number(
build_number: options[:build]
)
end
然后可以在一个lane中使用这个函数:
lane :appstore do |options| ··· prepare_version(options) ··· end
然后执行这个lane的时候:
$ fastlane appstore version:2.4.0 build:2.0
好啦,先说到这里吧,Fastlane能做的事情还有很多,大家可以去好好看看文档,研究一些高级的用法吧!
# fastlane
# 自动化打包
# ios
# fastlane打包
# 打包
# Python的iOS自动化打包实例代码
# Python实现iOS自动化打包详解步骤
# iOS使用fastlane实现持续集成的方法教程
# fastlane自动化打包iOS APP过程示例
# 自己的
# 新版本
# 文档
# 多个
# 是这样
# 会在
# 就可以
# 是一个
# 如果你
# 很好
# 你可以
# 每个人
# 工作流
# 说到
# 这一步
# 我们可以
# 想了
# 自定义
# 你所
# 不符合
相关文章:
如何打造高效商业网站?建站目的决定转化率
用v-html解决Vue.js渲染中html标签不被解析的问题
专业商城网站制作公司有哪些,pi商城官网是哪个?
魔毅自助建站系统:模板定制与SEO优化一键生成指南
如何配置WinSCP新建站点的密钥验证步骤?
成都品牌网站制作公司,成都营业执照年报网上怎么办理?
如何用y主机助手快速搭建网站?
零基础网站服务器架设实战:轻量应用与域名解析配置指南
实例解析Array和String方法
建站之星如何开启自定义404页面避免用户流失?
公司门户网站制作公司有哪些,怎样使用wordpress制作一个企业网站?
安徽网站建设与外贸建站服务专业定制方案
音响网站制作视频教程,隆霸音响官方网站?
如何在Golang中引入测试模块_Golang测试包导入与使用实践
建站之星安全性能如何?防护体系能否抵御黑客入侵?
昆明高端网站制作公司,昆明公租房申请网上登录入口?
网站设计制作书签怎么做,怎样将网页添加到书签/主页书签/桌面?
网站按钮制作软件,如何实现网页中按钮的自动点击?
打鱼网站制作软件,波克捕鱼官方号怎么注册?
制作网站的软件下载免费,今日头条开宝箱老是需要下载怎么回事?
如何选择美橙互联多站合一建站方案?
教学论文网站制作软件有哪些,写论文用什么软件
?
如何用西部建站助手快速创建专业网站?
关于BootStrap modal 在IOS9中不能弹出的解决方法(IOS 9 bootstrap modal ios 9 noticework)
Swift中switch语句区间和元组模式匹配
北京网页设计制作网站有哪些,继续教育自动播放怎么设置?
测试制作网站有哪些,测试性取向的权威测试或者网站?
微信小程序制作网站有哪些,微信小程序需要做网站吗?
建站主机SSH密钥生成步骤及常见问题解答?
南京做网站制作公司,南京哈发网络有限公司,公司怎么样,做网页美工DIV+CSS待遇怎么样?
交易网站制作流程,我想开通一个网站,注册一个交易网址,需要那些手续?
历史网站制作软件,华为如何找回被删除的网站?
为什么Go需要go mod文件_Go go mod文件作用说明
长沙做网站要多少钱,长沙国安网络怎么样?
如何生成腾讯云建站专用兑换码?
如何制作算命网站,怎么注册算命网站?
新网站制作渠道有哪些,跪求一个无线渠道比较强的小说网站,我要发表小说?
大连网站制作费用,大连新青年网站,五年四班里的视频怎样下载啊?
企业宣传片制作网站有哪些,传媒公司怎么找企业宣传片项目?
重庆市网站制作公司,重庆招聘网站哪个好?
我的世界制作壁纸网站下载,手机怎么换我的世界壁纸?
如何快速重置建站主机并恢复默认配置?
如何在阿里云虚拟主机上快速搭建个人网站?
如何在云服务器上快速搭建个人网站?
网站制作话术技巧,网站推广做的好怎么话术?
C++ static_cast和dynamic_cast区别_C++静态转换与动态类型安全转换
建站OpenVZ教程与优化策略:配置指南与性能提升
武汉网站设计制作公司,武汉有哪些比较大的同城网站或论坛,就是里面都是武汉人的?
seo网站制作优化,网站SEO优化步骤有哪些?
建站主机服务器选购指南:轻量应用与VPS配置解析
*请认真填写需求信息,我们会在24小时内与您取得联系。