Fastlane自动打包发布APP到蒲公英

Fastlane 是一款为 iOS 和 Android 开发者提供的自动化构建工具,它能够帮助开发者将 App 打包、签名、测试、发布、信息整理、提交 App Store 等工做完整的链接起来,实现彻底自动化的工做流,若是使用得当,能够显著的提升开发者的开发效率。ios

之前咱们都是打包完ipa,再手动上传到蒲公英,可是利用Fastlane,能够手动上传到蒲公英,提升效率。本人亲自对比过,在相同机械硬盘的状况下,自动打包比手动打包快了1分10秒!别小看这个一分多秒,效率就是金钱!api

1、安装Fastlane-->安装方法

2、安装蒲公英的 Fastlane 插件

一、在终端中,输入如下命令,便可安装蒲公英的 fastlane 插件。 fastlane add_plugin pgyerxcode

二、稍等几秒钟,若是出现相似下面的信息,就说明安装成功了: bash

3、在 Fastlane 启动蒲公英插件

一、在使用 Fastlane 以前,咱们首先须要在项目中初始化 Fastlane。首先进入 App 的开发目录,执行如下命令来初始化 Fastlane: fastlane initapp

二、执行上述命令后,Fastlane 会自动在 App 目录中生成 fastlane 目录,其中就会有 Fastlane 的配置文件 fastlane/Fastfile,能够用文本方式打开Fastfile,修改以下:ide

default_platform(:ios)
platform :ios do
  desc "Description of what the lane does"
  lane :beta do
    # add actions here: https://docs.fastlane.tools/actions
#build_app(export_method: "ad-hoc")
gym(export_method: "ad-hoc")
pgyer(api_key: "b0ea2xxxxxxx94afdxxx55exxxx132", user_key: "f9x4xxxxxxxxxxxxxxf0a9cx75xb")
  end
end
复制代码

注意: 以上的 api_keyuser_key,请开发者在本身帐号下的 应用管理 - App概述 - API 中能够找到,并替换到以上相应的位置。 在 Xcode 8.3Xcode 8.3 之后的版本中,对于 build_appexport_method 的值,须要根据开发者的打包类型进行设置,可选的值有:app-storead-hocdevelopmententerprise。对于 Xcode 8.3 如下的版本,则不须要设置 export_method工具

4、打包并自动上传 App 到蒲公英

一、通过以上配置后,就可使用 Fastlane 来打包 App,并自动上传到蒲公英了。在终端下,定位到项目所在目录,输入如下命令便可: fastlane beta测试

二、成功会见到以下信息 ui

同时,在APP目录下,会看到该APP最新的ipa

5、进阶用法

您也能够设置 App 上传到蒲公英时,设置密码:spa

lane :beta do
  build_app(export_method: "ad-hoc")
  pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", password: "123456", install_type: "2")
end
复制代码

设置一个版本更新时的描述信息:

lane :beta do
  build_app(export_method: "ad-hoc")
  pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", update_description: "update by fastlane")
end
复制代码

6、常见错误

一、提示no found scheme

这是让你勾选工程的Scheme,步骤就是打开你的xcode,点击Manage Schemes,在一堆三方库中找到你的项目Scheme,在后面的多选框中进行勾选,而后rm -rf fastlane文件夹,从新fastlane init一下就不会报错了。

二、提示locate not found xcode相似这样在mac本地找不到xcode的错误

使用sudo xcode-select -switch /Applications/Xcode.app/

参考:

一、https://baijiahao.baidu.com/s?id=1594756143908261537&wfr=spider&for=pc

二、https://www.pgyer.com/doc/view/fastlane

相关文章
相关标签/搜索