fastlane生命周期
- before_all在執(zhí)行 lane 之前只執(zhí)行一次
- before_each每次執(zhí)行 lane 之前都會執(zhí)行一次
- lane自定義的任務(wù)
- after_each每次執(zhí)行 lane 之后都會執(zhí)行一次
- after_all在執(zhí)行 lane 成功結(jié)束之后執(zhí)行一次
- error在執(zhí)行上述情況任意環(huán)境報錯都會中止并執(zhí)行一次
環(huán)境變量
從 fastlane 的設(shè)計體系上在各個地方都加入了環(huán)境變量的支持咙俩,每個擴展的參數(shù)、以及擴展需要共享給其他擴展和任務(wù)讀取的數(shù)據(jù)都是通過環(huán)境變量獲取松却,如下是我收集的比較常用的列表(需要寫入~/.bash_profile文件):
FASTLANE_USER credentials_manager Apple 開發(fā)者賬戶名 驗證通過后會保存 Keychain
FASTLANE_PASSWORD credentials_manager Apple 開發(fā)者賬戶密碼 驗證通過后會保存 Keychain
FASTLANE_TEAM_IDCERT_TEAM_ID producesigh Apple 團隊 ID
DELIVER_USER<br >PRODUCE_USERNAME deliverproduce iTunesConnect 賬戶名
DELIVER_PASSWORD deliver iTunesConnect 賬戶密碼
MATCH_PASSWORD match 證書加 / 解密密碼
FASTLANE_XCODE_LIST_TIMEOUT fastlane_core 獲取 iOS Scheme 的超時時間 默認(rèn) 10s
打包環(huán)境自我診斷(生成和同步證書)
# 開發(fā)環(huán)境證書
$ fastlane match development
# 產(chǎn)品環(huán)境證書
$ fastlane match appstore
# 內(nèi)測環(huán)境證書
$ fastlane match adhoc
如:
雜
#設(shè)置上傳testflight待測功能日志暴浦,取gitcommit最新10條記錄
changelog_from_git_commits( #設(shè)置上傳testflight待測功能日志,取gitcommit最新10條記錄
commits_count: 10,
pretty: "- (%ae) %s",
date_format: "short",
match_lightweight_tag: false,
merge_commit_filtering: "exclude_merges"
)
# 版本號自增
increment_build_number(xcodeproj: "jianzhimao")
# 項目名稱
scheme_name = "jianzhimao"
# Debug但還是指定打包時的配置項晓锻,默認(rèn)為Release / "DEBUG"
configuration = "DEBUG"
# info.plist的路徑
plist_path = "/Users/jianzhimao/Desktop/PartTimeCat_iOS/jianzhimao/jianzhimao/jianzhimao-Info.plist"
# version 版本號
#version = get_info_plist_value(path: plist_path, key: "CFBundleShortVersionString")
version = get_version_number(xcodeproj: "jianzhimao.xcodeproj")
# build 版本號
#build = get_info_plist_value(path: plist_path, key: "CFBundleVersion")
build = get_build_number(xcodeproj: "jianzhimao.xcodeproj")
# APP名稱
app_name = get_info_plist_value(path: plist_path, key: "CFBundleDisplayName")
#輸出文件
outputDir = "/Users/jianzhimao/Desktop/fastlane_build_兼職貓"
#當(dāng)前時間
currentTime = Time.now.strftime('%Y-%m-%d %H:%M')
#打包的ipa名稱
outputName = "v#{version}_build#{build}_#{configuration}_#{currentTime}"
# 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
before_all do
puts "http:// =========== 準(zhǔn)備開車 biuing =========== //"
puts last_git_commit
end
# 還不行
lane :testflightBiu do
desc "http:// =========== release biu =========== //"
gym
#上傳至testflight
upload_to_testflight(ipa: outputName ,
username:”1404565175@qq.com” ,
notes: "this is review note for the reviewer <3 thank you for reviewing")
end
# fir 還不行
lane :firBiu do
desc "http:// =========== fir biu =========== //"
gym
fir_api_token="e698f87eec6c3a9b09b959cab914e4e3" # fir token
firim(firim_api_token: fir_api_token) #上傳至fir
end
lane :biu do
desc "http:// =========== normal biu =========== //"
# 版本號自增
increment_build_number(xcodeproj: "jianzhimao")
# 項目名稱
scheme_name = "jianzhimao"
# Debug但還是指定打包時的配置項歌焦,默認(rèn)為Release / "DEBUG"
configuration = "DEBUG"
# info.plist的路徑
plist_path = "/Users/jianzhimao/Desktop/PartTimeCat_iOS/jianzhimao/jianzhimao/jianzhimao-Info.plist"
# version 版本號
#version = get_info_plist_value(path: plist_path, key: "CFBundleShortVersionString")
version = get_version_number(xcodeproj: "jianzhimao.xcodeproj")
# build 版本號
#build = get_info_plist_value(path: plist_path, key: "CFBundleVersion")
build = get_build_number(xcodeproj: "jianzhimao.xcodeproj")
# APP名稱
app_name = get_info_plist_value(path: plist_path, key: "CFBundleDisplayName")
#輸出文件
outputDir = "/Users/jianzhimao/Desktop/fastlane_build_兼職貓"
#當(dāng)前時間
currentTime = Time.now.strftime('%Y-%m-%d %H:%M')
#打包的ipa名稱
outputName = "v#{version}_build#{build}_#{configuration}_#{currentTime}"
# 開干
gym(
scheme: scheme_name, #你項目的scheme,
workspace:"#{scheme_name}.xcworkspace",
clean: false, # 在打包前是否先執(zhí)行clean。
export_xcargs:"-allowProvisioningUpdates",
output_directory: outputDir, # 指定.pa文件的輸出目錄砚哆,默認(rèn)為當(dāng)前文件夾独撇。
output_name: outputName, # 指定生成的ipa文件的名稱,應(yīng)包含文件擴展名。
configuration: configuration, # 指定打包時的配置項纷铣,默認(rèn)為Release卵史。
silent: true, # 是否隱藏打包時不需要的信息。
include_symbols: false,
include_bitcode: false,
export_method: "ad-hoc", # 指定導(dǎo)出ipa時使用的方法搜立,可用選項:app-store, ad-hoc, package, enterprise, development, developer-id
)
end
#--發(fā)布AppStore上的版本配置
lane :appstoreBiu do
# 版本號自增
increment_build_number(xcodeproj: "jianzhimao")
# 項目名稱
scheme_name = "jianzhimao"
# Debug但還是指定打包時的配置項以躯,默認(rèn)為Release / "DEBUG"
configuration = "DEBUG"
# info.plist的路徑
plist_path = "/Users/jianzhimao/Desktop/PartTimeCat_iOS/jianzhimao/jianzhimao/jianzhimao-Info.plist"
# version 版本號
#version = get_info_plist_value(path: plist_path, key: "CFBundleShortVersionString")
version = get_version_number(xcodeproj: "jianzhimao.xcodeproj")
# build 版本號
#build = get_info_plist_value(path: plist_path, key: "CFBundleVersion")
build = get_build_number(xcodeproj: "jianzhimao.xcodeproj")
# APP名稱
app_name = get_info_plist_value(path: plist_path, key: "CFBundleDisplayName")
#輸出文件
outputDir = "/Users/jianzhimao/Desktop/fastlane_build_兼職貓"
#當(dāng)前時間
currentTime = Time.now.strftime('%Y-%m-%d %H:%M')
#打包的ipa名稱
outputName = "v#{version}_build#{build}_#{configuration}_#{currentTime}"
sigh(
app_identifier: "com.jiuwei.jianzhimao",
username: "1404565175@qq.com"
)
gym(
scheme: scheme_name, #你項目的scheme,
configuration: "Release",
silent: true,
clean: true,
workspace:"#{scheme_name}.xcworkspace",
include_bitcode: false,
output_directory: outputDir, # 指定.pa文件的輸出目錄,默認(rèn)為當(dāng)前文件夾啄踊。
output_name: outputName, # 指定生成的ipa文件的名稱忧设,應(yīng)包含文件擴展名。
export_xcargs: "-allowProvisioningUpdates”,
)
deliver(
submit_for_review: false,
skip_screenshots: true,
skip_metadata: true
)
end
lane : testflight_beta do # beta是打包的腳本命令 打包上傳時執(zhí)行 fastlane beta
# 版本號自增
increment_build_number(xcodeproj: "jianzhimao")
# 項目名稱
scheme_name = "jianzhimao"
# Debug但還是指定打包時的配置項颠通,默認(rèn)為Release / "DEBUG"
configuration = "DEBUG"
# info.plist的路徑
plist_path = "/Users/jianzhimao/Desktop/PartTimeCat_iOS/jianzhimao/jianzhimao/jianzhimao-Info.plist"
# version 版本號
#version = get_info_plist_value(path: plist_path, key: "CFBundleShortVersionString")
version = get_version_number(xcodeproj: "jianzhimao.xcodeproj")
# build 版本號
#build = get_info_plist_value(path: plist_path, key: "CFBundleVersion")
build = get_build_number(xcodeproj: "jianzhimao.xcodeproj")
# APP名稱
app_name = get_info_plist_value(path: plist_path, key: "CFBundleDisplayName")
#輸出文件
outputDir = "/Users/jianzhimao/Desktop/fastlane_build_兼職貓"
#當(dāng)前時間
currentTime = Time.now.strftime('%Y-%m-%d %H:%M')
#打包的ipa名稱
outputName = "v#{version}_build#{build}_#{configuration}_#{currentTime}"
build_app(workspace: "#{scheme_name}.xcworkspace", scheme: scheme_name) # 開始打包-打包時使用的配置文件
upload_to_testflight #打包完成后-上傳到testflight
end
end