安裝fastlane
sudo gem install fastlane -NV -n /usr/local/bin
cd到項(xiàng)目所在目錄
cd ......項(xiàng)目
初始化fastlane
fastlane init
添加蒲公英的插件
fastlane add_plugin pgyer
根目錄下會(huì)生成fastlane文件夾,里面會(huì)用到Fastfile文件,至于Appfile可用可不用红氯,我沒用到
項(xiàng)目中兩個(gè)target穆端,一個(gè)測(cè)試一個(gè)正式環(huán)境绘盟,下面新建兩個(gè)lane
default_platform(:ios)
platform :ios do
#正式環(huán)境下的打包
lane :uploadToPgy do
schemeName = "正式環(huán)境下的項(xiàng)目名"
app_identifier = "正式環(huán)境下的bundle id"
apple_id = "開發(fā)者主賬號(hào)"
export_method = "ad-hoc"
#從蒲公英平臺(tái)拿到的api_key和user_key
api_key = "xxx"
user_key = "x'x"
puts "請(qǐng)輸入版本描述:"
desc = STDIN.gets
puts "開始打包 #{schemeName}"
# 開始打包
gym(
scheme: "#{schemeName}",
output_name:"#{schemeName}",
clean:true,
configuration:"Release",#打包正式環(huán)境用release 區(qū)別下面
export_method:"#{export_method}",
output_directory:"./fastlane/build",
)
puts "開始上傳到蒲公英"
pgyer(update_description: "#{desc}", api_key: "#{api_key}", user_key: "#{user_key}")
#在上傳完ipa后概而,打開ipa的存放文件夾,起到提示上傳完成的作用
system "open ../fastlane/build"
end
#測(cè)試環(huán)境下打包
lane :uploadToPgyDev do
schemeName = "測(cè)試環(huán)境下的項(xiàng)目target名"
app_identifier = "測(cè)試環(huán)境下的bundle id"
apple_id = "開發(fā)者主賬號(hào)"
export_method = "ad-hoc"
api_key = "xxx"
user_key = "xx"
puts "請(qǐng)輸入版本描述:"
desc = STDIN.gets
puts "開始打包 #{schemeName}"
# 開始打包
gym(
scheme: "#{schemeName}",
output_name:"#{schemeName}",
clean:true,
configuration:"Debug",#打包測(cè)試環(huán)境用debug
export_method:"#{export_method}",
output_directory:"./fastlane/build",
)
puts "開始上傳到蒲公英"
pgyer(update_description: "#{desc}", api_key: "#{api_key}", user_key: "#{user_key}")
system "open ../fastlane/build"
end
end
cd 到項(xiàng)目 執(zhí)行下面掷豺,會(huì)讓你選擇打包哪個(gè)環(huán)境1和2
fastlane