自动化打包之fastlane--(7) 常用actons操作

本文详细介绍了Fastlane在iOS自动化打包过程中的常用操作,包括gym用于编译和打包,increment_build_number和increment_version_number自动调整版本号,sigh和match管理代码签名,以及deliver进行应用发布。此外,还提到了与cocoapods的配合使用和其他辅助功能如清理DerivedData、项目配置修改等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自动化打包之fastlane–(1) 研究之必须提前了解的几点

自动化打包之fastlane–(2) fastlane init图文教程

自动化打包之fastlane–(3) 安装fir插件图文教程

自动化打包之fastlane–(4) 安装其他插件

自动化打包之fastlane–(5) 自动打包到蒲公英

自动化打包之fastlane–(6) ruby使用小结

自动化打包之fastlane–(7) 常用actons操作

自动化打包之fastlane–(8) 代码签名和项目配置

自动化打包之fastlane–(9) 常见错误

文章目录

1. Building 编译

###1.1. gym###

  • 官方链接
  • gymbuild_ios_app的别名
  • build_appbuild_ios_app的别名
  • gymfastlane 的一部分: 可以更快速地编译和打包
  • 主要作用是用来编译和打包iOSAPP的,简化了xcodebuild的命令行操作
  • shenzhen(另一款开源库)的替代者
  • 自动生成ips包和dSYM文件
  • 可以动态滴配置相关参数和环境变量

gym使用示例和Parameters参数

gym(
	key1:value1,
	key2:value2,
	key3:value3
)

//gym和build_app都是build_ios_app的别名
build_ios_app(
  workspace: "MyApp.xcworkspace",
  configuration: "Debug",
  scheme: "MyApp",
  silent: true,
  clean: true,
  output_directory: "path/to/dir", # Destination directory. Defaults to current directory.
  output_name: "my-app.ipa",       # specify the name of the .ipa file to generate (including file extension)
  sdk: "iOS 11.1"        # use SDK as the name or path of the base SDK when building the project.
)

Parameters

  • workspace : 使用cocoapods后的工程文件路径
  • project : 项目文件路径
  • scheme : 项目的白名单,在Manage schemes中将其设置为shared状态
  • output_directory : 打包出来的ipa包存储的位置 .
  • output_name : 打包出的ipa包名称
  • configuration : 编译APP是的配置,默认是 release
  • silent : 编译时隐藏不必要的信息,默认是false
  • export_method : 打包的类型: app-store, ad-hoc, package, enterprise, development, developer-id
  • export_options : 导出的选项设置,新Xcode允许导出时修改plist文件
  • build_path : 打archive包的存储路径
  • buildlog_path : 存储bulid的log
  • sdk : 打包时使用的sdk

###1.2. cocoapods###

  • cocoapods项目中使用pod intall,和cocoapods相关的项目,使用pod相关的命令即可,不用在使用fastlane命令
  • 如果项目中使用cocoapods,在Gemfile中添加gem ‘cocoapods’

这里写图片描述

###1.3 其他###

//Xcode相关
clear_derived_data
xcode_select
ensure_xcode_version
verify_xcode
xcode_install
gradle : 安卓相关

这里写图片描述

##2. Project 项目 ##

###2.1 increment_build_number###

increment_build_number 自动增加项目的build号

这里写图片描述

increment_build_number # automatically increment by one

increment_build_number(
  build_number: "75" # set a specific number
)

increment_build_number(
  build_number: 75, # specify specific build number (optional, omitting it increments by one)
  xcodeproj: "./path/to/MyApp.xcodeproj" # (optional, you must specify the path to your main Xcode project if it is not in the project root directory)
)

build_number = increment_build_number

###2.2 increment_version_number###

increment_version_number 增加项目的版本号

这里写图片描述

###2.3 set_info_plist_value ###

  • 设置info.plist的信息
    fastlane action set_info_plist_value
set_info_plist_value(path: "./Info.plist", key: "CFBundleIdentifier", value: "com.krausefx.app.beta")

set_info_plist_value(path: "./MyApp-Info.plist", key: "NSAppTransportSecurity", subkey: "NSAllowsArbitraryLoads", value: true, output_file_name: "./Info.plist")

###2.4 其他###

这里写图片描述

##3. Code Signing 代码签名 ##

###3.1 sigh###
官方文档

  • get_provisioning_profile 的别名
  • 用于创建,更新,下载,修改描述文件provisioning profiles
  • 支持四种模式App Store, Ad Hoc, Development Enterprise
  • 支持多个teams 支持多个苹果账号
//所有相关操作
fastlane sigh
//测试
fastlane sigh --adhoc
//开发
fastlane sigh --development
//下载所有
fastlane sigh download_all
//强制操作
fastlane sigh --force
//跳过
fastlane sigh --skip_certificate_verification
//修复
fastlane sigh repair
//
fastlane sigh resign
//sign是get_provisioning_profile的别名
get_provisioning_profile(
  adhoc: true,
  force: true,
  filename: "myFile.mobileprovision"
)

这里写图片描述

###3.2 match###

  • sync_code_signing 的别名
  • 管理证书certificates,需要设置一个git仓库来存储和管理证书和配置文件
  • 匹配certificatesProvisioning profile
  • 在项目中会生成一个Matchfile文件
  • 第一次在点到上使用的时候,会要求输入git仓库的密码,以便安全地从仓库获取存储的证书和描述文件
  • match操作完成后,git仓库会有两个文件夹certs包含所有证书,profiles包含所有描述文件,项目中还会有个README.md的文件,帮助新人了解这些事宜
//会自动在需要的时候创建证书和描述文件,并更新到你设置的git仓库中
fastlane match appstore
fastlane match development

查看电脑中所有的配置文件
~/Library/MobileDevice/Provisioning Profiles

lane :certificates do
  match(app_identifier: ["com.krausefx.app1", "com.krausefx.app2", "com.krausefx.app3"], readonly: true)
end
//使用示例
match(type: "appstore")

match(git_url: "https://github.com/fastlane/certificates",
      type: "development")

match(git_url: "https://github.com/fastlane/certificates",
      type: "adhoc",
      app_identifier: "tools.fastlane.app")

match(git_url: "https://github.com/fastlane/certificates",
      type: "enterprise",
      app_identifier: "tools.fastlane.app")

Registering new devices注册新设备

//将新设备放到项目的信息devices.txt文件中
lane :beta do
  register_devices(devices_file: "./devices.txt")
  match(type: "adhoc", force_for_new_devices: true)
end

这里写图片描述

###3.3 cert###

  • get_certificates 别名
  • 在电脑中安装签名证书,包括创建私钥,创建签名请求,下载和安装证书,将生成的证书导入到电脑钥匙串中,不会重置已经存在的证书
lane :beta do
  cert
  sigh(force: true)
end
get_certificates
cert # alias for "get_certificates"
get_certificates(
  development: true,
  username: "user@email.com"
)

这里写图片描述

###3.4 其他###

这里写图片描述

##4. Releasing 发布 ##

###4.1 deliver###

官方链接

  • upload_to_app_store的别名,appstore也是其别名
  • 上传屏幕截图,APP提交相关设置,二进制文件到 iTunes Connect
  • 提交APP打App Store
  • 生成一个漂亮的APP提交审核信息相关html查看文件

操作步骤

  • cd [your_project_folder]
  • fastlane deliver init
  • 输入 iTunes Connect 凭证
  • 输入 app identifier
deliver
deliver(
  submit_for_review: true,
  force: true,
  metadata_path: "./metadata"
)

##5. Source Control git管理 ##

  • 东西太多了,回头再总结
ActionDescription
ensure_git_status_cleanRaises an exception if there are uncommitted git changes
git_branchReturns the name of the current git branch, possibly as managed by CI ENV vars
last_git_commitReturn last git commit hash, abbreviated commit hash, commit message and author
reset_git_repoResets git repo to a clean state by discarding uncommitted changes
changelog_from_git_commitsCollect git commit messages into a changelog
number_of_commitsReturn the number of commits in current git branch
git_pullExecutes a simple git pull command
last_git_tagGet the most recent git tag
push_to_git_remotePush local changes to the remote branch
add_git_tagThis will add an annotated git tag to the current branch
commit_version_bumpCreates a 'Version Bump' commit. Run after increment_build_number
git_tag_existsChecks if the git tag with the given name exists in the current repo
ensure_git_branchRaises an exception if not on a specific git branch
git_commitDirectly commit the given file with the given message
push_git_tagsPush local tags to the remote - this will only push tags
git_addDirectly add the given file or all files
get_build_number_repositoryGet the build number from the current repository
set_github_releaseThis will create a new release on GitHub and upload assets for it
create_pull_requestThis will create a new pull request on GitHub
get_github_releaseThis will verify if a given release version is available on GitHub
hg_ensure_clean_statusRaises an exception if there are uncommitted hg changes
hg_commit_version_bumpThis will commit a version bump to the hg repo
hg_pushThis will push changes to the remote hg repository
hg_add_tagThis will add a hg tag to the current branch
github_apiCall a GitHub API endpoint and get the resulting JSON response
commit_github_fileThis will commit a file directly on GitHub via the API
git_submodule_updateExecutes a git submodule command

##6. Notifications 通知 ##

  • 主要用于自动化打包成功和失败后的通知处理

这里写图片描述

…未完,待续…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值