1. 安装xcode命令行工具
- fastlane官方推荐的在终端 xcode-select –install
- 苹果官网下载(传送门),推荐使用这种!
2. 安装fastlane
- fastlane需要依赖Ruby
- 检查Ruby的版本,终端 ruby –version
- ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
- 支持 2.4 至 2.7 版本
- 官方给出三个方法安装
- 此处推荐 sudo gem install fastlane 安装
- 其他方法(传送门)
3. 测试fastlane
- 环境变量已经配置
- 在任意目录都可以执行fastlane命令
- 环境变量未配置
- 添加用户变量 vim ~/.bash_profile
- 添加内容 export PATH=/usr/local/bin:$PATH
- 保存退出,使用 source ~/.bash_profile 来使配置立即生效
- 现在配置完成
4. 项目中初始化fastlane
- 在项目的根目录下
- OC项目使用 fastlane init
- Swift项目使用 fastlane init swift
What would you like to use fastlane for?
1.Automate screenshots
2.Automate beta distribution to TestFlight
3.Automate App Store distribution
4.Manual setup - manually setup your project to automate your tasks
1 自动截屏。(帮助我们截取App的显示到appstore上的 截图)
2 自动发布beta到TestFlight上,用于内测。
3 自动打包发布到AppStore上。
4 手动设置。
复制代码
- 上传fir.im此处选择 4
5. 配置Gemfile文件
source "https://rubygems.org"
gem "fastlane"
gem "cocoapods", '1.10.0'
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
复制代码
- 如果项目中使用了cocoapods,那么此处一定要配置,而且是加上cocoapods版本号
- 终端执行 bundle install
6. 配置fastlane->fastfile文件
- 具体信息可以在网上自行搜索,上传到fir.im这些配置就够了
default_platform(:ios)
platform :ios do
desc "上传iOSApp到fir.im平台"
# 打包上传执行的命令名: fastlane fir
lane :fir do
# 如果你没有申请adhoc证书,sigh会自动帮你申请,并且添加到Xcode里
# sigh(adhoc: true)
# 以下两个action来自fastlane-plugin-versioning,
# 第一个递增 Build,第二个设定Version。
# 如果你有多个target,就必须指定target的值,否则它会直接找找到的第一个plist修改
# 在这里我建议每一个打的包的Build都要不一样,这样crash了拿到日志,可以对应到ipa上
scheme = "xxxApp"
ipa_dir = "./fastlane_build/"+Time.new.strftime('%Y-%m-%d')
ipa_name = 'xxxApp_Fir.ipa'
# increment_build_number_in_plist(
# target: scheme,
# build_number: '20210427001'
# )
# increment_version_number_in_plist(
# target: scheme,
# version_number: '3.0.0'
# )
# gym用来编译ipa
gym(
workspace: scheme + ".xcworkspace",
scheme: scheme,
export_options: {
method: "ad-hoc", # 指定打包方式 ["app-store", "ad-hoc", "package", "enterprise", "development", "developer-id"]
teamID: "xxxx" # 在developer网站获取
},
xcargs: "-allowProvisioningUpdates",
output_directory: ipa_dir,
output_name: ipa_name
)
# 上传ipa到fir.im服务器,在fir.im获取firim_api_token
firim(firim_api_token: "xxxxxx") # token 在fir 上查看。
end
end
复制代码
7. 加载插件
- fastlane add_plugin versioning(可以指定版本)
- fastlane add_plugin firim(上传到fir.im)
8. 打包上传
- 终端执行 fastlane fir
完结
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END