1. 安装xcode命令行工具
- fastlane官方推荐的在终端 xcode-select --install
- 苹果官网下载(传送门),推荐使用这种!
2. 安装fastlane
- 检查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
- 添加用户变量 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 手动设置。
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平台"
lane :fir do
scheme = "xxxApp"
ipa_dir = "./fastlane_build/"+Time.new.strftime('%Y-%m-%d')
ipa_name = 'xxxApp_Fir.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
)
firim(firim_api_token: "xxxxxx")
end
end
7. 加载插件
- fastlane add_plugin versioning(可以指定版本)
- fastlane add_plugin firim(上传到fir.im)
8. 打包上传
完结