iOS-Fastlane从0到1配置自动打包

项目进入测试阶段,频繁的打包发布会耗费团队很多的时间,急需搭建一个自动化打包发布的平台,将我们从繁琐的打包发布流程中解放出来。

经调研,Fastlane可以实现一行命令实现打包工作,不需要时时等待操作下一步,节省打包的时间去做其他的事。

Fastlan安装步骤

fastlane前置准备工作:
① 安装xcode,且安装了Xcode命令行工具;

allison@bogon Desktop % xcode-select --install
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

注意: 出现 error: command line tools are already installed, use "Software Update" to install updates 代表安装成功。

② 安装了ruby,且要求版本大于2.0.0;

allison@bogon Desktop % ruby -v

ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin21]

③ 确保终端为 https://gems.ruby-china.com/ 镜像;

allison@bogon Desktop % gem sources
gem sources
*** CURRENT SOURCES ***

https://gems.ruby-china.com/

④ 确保为Automatically manage signing 自动管理证书。(手动管理证书需要配置match来管理证书)

image.png
Fastlane 正式安装流程:
1.安装fastlane
allison@bogon Desktop % sudo gem install fastlane --verbose
sudo gem install fastlane --verbose
Password:

这里需要输入密码,安装完成执行fastlane --version,确保正确安装。

allison@bogon Desktop % fastlane --version

fastlane installation at path:
/Users/allison/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/fastlane-2.204.3/bin/fastlane
-----------------------------
[✔] 🚀 
fastlane 2.204.3
2.初始化Fastlane

cd到项目目录执行,然后执行Fastlane初始化命令

allison@bogon fastlane-match % fastlane init
image.png

此时fastlane列出几个选项,需要我们告诉它使用fastlane需要执行哪种操作:

  • 第一种获取App Store的App预览照片。
  • 第二种打包上传至TestFlight工具上。
  • 第三种打包上传到App Store。
  • 第四种自定义打包方式。

以上四种方式大家可以根据自己的需要自行选择,这里我选择4自定义打包方式。出现$ bundle update,需要耐心等待(我等了10分钟)。

出现以下截图说明已经创建成功:

image.png

此时只需要我们需要敲3次回车键即可,直到该命令运行结束,我们会看到如下创建的文件:

image.png

Appfile是编辑我们相关App和开发者账号信息的,如果没有出现账号密码输入的步骤,这里需要修改为项目相关的信息。

image.png

Fastfile是我们对自动打包这个过程的完整配置,本人的Fastfile文件内容如下,详细的语法可看 fastlane docs官网fastlane docs

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do

    desc "打测试包上传到蒲公英"
    lane :pgy do
        build_app(
            workspace: "temp.xcworkspace",
            scheme: "temp",
            export_method: "development",
            output_directory: "./ipa/ad_hoc"
        )
    
        #蒲公英的配置 替换为自己的api_key和user_key
        pgyer(api_key: "xxxxxx", user_key: "xxxxxx", update_description: "xxxxxx")
    end
end

终端执行 fastlane ios pgy,等待几分钟,出现success提示即打包成功。

image.png

至此,fastlane打包到此完成,记录学习安装过程。

END !

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值