自动化打包之fastlane–(1) 研究之必须提前了解的几点
自动化打包之fastlane–(2) fastlane init图文教程
自动化打包之fastlane–(3) 安装fir插件图文教程
文章目录
1. Building 编译
###1.1. gym###
- 官方链接
gym
是build_ios_app
的别名build_app
是build_ios_app
的别名gym
是fastlane
的一部分: 可以更快速地编译和打包- 主要作用是用来编译和打包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
: 编译时隐藏不必要的信息,默认是falseexport_method
: 打包的类型:app-store
,ad-hoc
,package
,enterprise
,development
,developer-id
export_options
: 导出的选项设置,新Xcode允许导出时修改plist文件build_path
: 打archive包的存储路径buildlog_path
: 存储bulid的logsdk
: 打包时使用的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仓库来存储和管理证书和配置文件 - 匹配
certificates
和Provisioning 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管理 ##
- 东西太多了,回头再总结
Action | Description |
---|---|
ensure_git_status_clean | Raises an exception if there are uncommitted git changes |
git_branch | Returns the name of the current git branch, possibly as managed by CI ENV vars |
last_git_commit | Return last git commit hash, abbreviated commit hash, commit message and author |
reset_git_repo | Resets git repo to a clean state by discarding uncommitted changes |
changelog_from_git_commits | Collect git commit messages into a changelog |
number_of_commits | Return the number of commits in current git branch |
git_pull | Executes a simple git pull command |
last_git_tag | Get the most recent git tag |
push_to_git_remote | Push local changes to the remote branch |
add_git_tag | This will add an annotated git tag to the current branch |
commit_version_bump | Creates a 'Version Bump' commit. Run after increment_build_number |
git_tag_exists | Checks if the git tag with the given name exists in the current repo |
ensure_git_branch | Raises an exception if not on a specific git branch |
git_commit | Directly commit the given file with the given message |
push_git_tags | Push local tags to the remote - this will only push tags |
git_add | Directly add the given file or all files |
get_build_number_repository | Get the build number from the current repository |
set_github_release | This will create a new release on GitHub and upload assets for it |
create_pull_request | This will create a new pull request on GitHub |
get_github_release | This will verify if a given release version is available on GitHub |
hg_ensure_clean_status | Raises an exception if there are uncommitted hg changes |
hg_commit_version_bump | This will commit a version bump to the hg repo |
hg_push | This will push changes to the remote hg repository |
hg_add_tag | This will add a hg tag to the current branch |
github_api | Call a GitHub API endpoint and get the resulting JSON response |
commit_github_file | This will commit a file directly on GitHub via the API |
git_submodule_update | Executes a git submodule command |
##6. Notifications 通知 ##
- 主要用于自动化打包成功和失败后的通知处理
…未完,待续…