采用Fastlane自动打包,如何区分版本,例如分别打测试环境和线上环境
方式一:
参考文章
iOS中如何使用多个Target去管理你的项目环境版本(测试环境与线上环境)
https://www.jianshu.com/p/23cc84d40423
方式二:使用xcconfig文件来配置
参考文章:
https://www.jianshu.com/p/e9e3948b4888?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
个人是用方式二用来打包的。
fastlane文件配置如下
# 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 "Description of what the lane does"
time = Time.new
timeString = time.strftime("%Y-%m-%d_%H")
output_name = "test_#{timeString}"
before_all do
puts "hello,this is before all lane"
end
lane :test do
puts "开始打包测试环境"
gym(
scheme: "dongcheng_hotel", #项目名称
export_method:"development",#打包输出种类
output_directory: "/Users/appleJun/Desktop/dossen/workspace", # 打包后的 ipa 文件存放的目录
output_name: "#{output_name}" # ipa文件名
)
end
lane :product do
puts "开始打包生产环境"
gym(
scheme: "dongcheng_hotel", #项目名称
export_method:"development",#打包输出种类
configuration:"Release Product",
output_directory: "/Users/appleJun/Desktop/dossen/workspace", # 打包后的 ipa 文件存放的目录
output_name: "生产环境" # ipa文件名
)
end
end
注意参数,configuration:"Release Product",打包生产环境的时候会读取这个配置文件,xcconfig的,工程中对应如下
Release Product对应的是生产环境。打包测试环境的时候,以上参数没写,会默认读取Debug配置文件的
打包命令
切换到工程目录cd /Users/appleJun/Desktop/dossen/workspace
1.打包测试环境
输入命令fastlane test
2.打包生产环境
输入命令fastlane product