Fastlane iOS持续集成自动打包发布。

fastlane是为您的 iOS 和 Android 应用程序自动化测试部署和发布的最简单方法。🚀 它可以处理所有繁琐的任务,例如生成屏幕截图、处理代码签名和发布您的应用程序。

fastlane官网
youtube

1:Fastlane 功能大全

Fastlene.png

2:iOS的Fastlane|安装Fastlane|向FastlaneProduce注册应用

👉2.1 环境安装

*Homebrew 👉 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
*Ruby 👉 brew install ruby
*Bundler 👉 gem install bundler
*Fastlane 👉 brew install fastlane
*Git 👉 brew install git
*xCode命令行👉 xcode-select --install

Environment.png

👉2.2 设定Fastlane

*Fastlane初始化 👉 fastlane init

Settihg.png

👉2.3 Produce (有2总方式,1. 命令行 2. Fastfile 自定义lane文件配置)

Oroduce.png

2.3.1命令行 👉 fastlane produce

produce.png

2.3.1 Fastfile自定义lane文件配置 👉 fastlane register_app

oroduce.png

3:iOS的Fastlane| Cert和Sigh 签名(certificates)和配置文件(provisioning profiles)

Fastlane tor ios.png

3.1 创建证书和签名文件

👉 fastlane cert
👉 fastlane sigh

3.2 创建lane通道,相同的参数可以提取到appfile中 后

👉 fastlane get_dev_certs

default platfora( ios).png

4:iOS的Fastlane| Match 证书管理

Git repo.png

4.1 设置match git仓库

👉 fastlane match init

$ fastlane match init    
[✔] 🚀 
[16:28:30]: fastlane match supports multiple storage modes, please select the one you want to use:
1. git
2. google_cloud
3. s3
?  1
[16:28:32]: Please create a new, private git repository to store the certificates and profiles there
[16:28:32]: URL of the Git Repo: https://github.com/yanmingLiu/HJStoreBCertificate.git
[16:28:59]: Successfully created './fastlane/Matchfile'. You can open the file using a code editor.
[16:28:59]: You can now run `fastlane match development`, `fastlane match adhoc`, `fastlane match enterprise` and `fastlane match appstore`
[16:28:59]: On the first run for each environment it will create the provisioning profiles and
[16:28:59]: certificates for you. From then on, it will automatically import the existing profiles.
[16:28:59]: For more information visit https://docs.fastlane.tools/actions/match/

❌这里注意可能会给你报这个错误,是因为github用新的个人访问令牌替换原始的密码。按照github文档创建一个个人访问令牌来代替命令行或 API 中的密码。然后删除Matchfile,重新fastlane match init克隆输入密码的时候用最新的令牌就好了。

[15:35:42]: Cloning remote git repo...
[15:35:42]: If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.
Cloning into '/var/folders/yd/wrnrn3s94s174b6q9ktk60zm0000gn/T/d20211026-3696-ga67md'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
[15:35:43]: Exit status: 128
[15:35:43]: Error cloning certificates repo, please make sure you have read access to the repository you want to use
[15:35:43]: Run the following command manually to make sure you're properly authenticated:
[15:35:43]: $ git clone https://github.com/yanmingLiu/HJStoreBCertificate.git /var/folders/yd/wrnrn3s94s174b6q9ktk60zm0000gn/T/d20211026-3696-ga67md

[!] Error cloning certificates git repo, please make sure you have access to the repository - see instructions above

4.2 matchFile文件生成后,配置development appstore adhoc 所有的开发需要的签名资料都在git仓库中了

👉 fastlane match development
👉 fastlane match appstore
👉 fastlane match adhoc
现在证书管理全部上传到git仓库中了,并生成了如何在新机器上使用的README.md。

4.3 添加新设备通道

4.3.1 matchfile中添加force_for_new_devices(true)

9it.url(gitegithus.coeirgohongthastutorial-certifAcate.gkt”).png

4.3.2 新加同步设备通道 和 新创建一个Devicefile存储设备

👉 cd fastlane
👉 touch Devicefile
👉 fastlane sync_all_development


Device Nane.png
default platform(1os).png
Fastfile 因为之前是先有项目在集成fastlane 2、3步并不是用这个方式生成的。有2个lane 一个是release自动打包并上传appstore ,一个是pgyer_debug自动打包并上传蒲公英分发。
# 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 "Push a new release build to the App Store"
  lane :release do
    increment_build_number(xcodeproj: "HJStoreB.xcodeproj")
    build_app(workspace: "HJStoreB.xcworkspace", scheme: "HJStoreB")
    upload_to_app_store
  end


  # debug测试包
  desc "Push a new debug build to the pgyer.com"
  ipa_dir  = "fastlane_build/"
  ipa_name = "debug" + Time.new.strftime('%Y-%m-%d_%H:%M')

  lane :pgyer_debug do |options|
    gym(
    # 打包前clean项目
    clean: true, 
    # 构建时,隐藏不必要的信息  
    silent: true,           
    # bitcode
    include_bitcode: false,                             
    # 导出方式 app-store、ad-hoc、enterprise、development
    export_method: "ad-hoc",        
    # scheme    
    scheme: "HJStoreB",                 
    # 环境 Debug、Release
    configuration: "Debug",             
    # ipa的存放目录
    output_directory: "/Users/lym/Desktop/Archive",
    # 输出ipa的文件名为当前的build号
    output_name: ipa_name + get_build_number                
    )

    # 蒲公英
    pgyer(
      api_key: "4123246b31d0023aa348e8ee0cc7f987", 
      user_key: "e3bf8adb2f886e1557bfc7284d4e27ac",
      update_description:  options[:desc]
      )

  end

  # 同步设备
  lane :sync_all_development do
    sync_device_info
    match(type: "development")
  end

  lane :sync_device_info do
    register_devices(
      devices_file:"fastlane/Devicefile"
      )
  end

end
Devicefile 需要按苹果官网的方式,试了一下自己写的文件中间的空格不管是tab还是4个空格,在执行fastlane sync_all_development会报错,最后还是下载苹果的samples文件复制进来的。示例:
Device ID   Device Name Device Platform
A123456789012345678901234567890123456789    NAME1   ios
B123456789012345678901234567890123456789    NAME2   ios
A5B5CD50-14AB-5AF7-8B78-AB4751AB10A8    NAME3   mac
A5B5CD50-14AB-5AF7-8B78-AB4751AB10A7    NAME4   mac
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,902评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,037评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,978评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,867评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,763评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,104评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,565评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,236评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,379评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,313评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,363评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,034评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,637评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,719评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,952评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,371评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,948评论 2 341

推荐阅读更多精彩内容