[英]Passing a Build Number to xcargs in Fastlane/Gym
我有一個帶有一些應用擴展的應用。 為了讓應用程序擴展和主應用程序使用相同的版本和內部版本號,我配置了一個用戶定義的變量,例如“MY_BUILD_NUMBER”和“MY_VERSION”。 在我的應用程序和我的擴展 Info.plist 文件中,我只是通過${MY_BUILD_NUMBER}
和${MY_VERSION}
加載這些變量。
這個過程非常適合保持我的版本和構建同步。 我現在正在嘗試研究是否可以通過健身房將 Jenkins 的內部版本號傳遞到 fastlane 並更新我的 xcargs。 但是,我一直未能使用所需的引號使這項工作正常進行。
這些示例表明我需要像這樣設置它:
gym(xcargs: "my_build_number='123'")
但是當我嘗試將其作為選項傳遞時,我可以傳遞內部版本號“123”。 但是我正在努力解決如何插入到 xcargs "my_build_number='123'"
中我需要的字符串中。
有沒有人成功做過這樣的事情可以提供一些見解? 我需要以某種方式轉義引號嗎?
我們在gym
之前在fastlane
同時設置應用程序和擴展的捆綁版本:
set_info_plist_value(
key: 'CFBundleVersion',
value: build_number,
path: info_plist_file
)
version_string = get_info_plist_value(
key: 'CFBundleShortVersionString',
path: info_plist_file
)
update_info_plist(
xcodeproj: project_filepath,
plist_path: notification_service_info_plist_relpath,
block: lambda do |plist|
plist['CFBundleVersion'] = build_number
plist['CFBundleShortVersionString'] = version_string
end
)
我可以使用以下語法將變量作為 xcarg 傳遞:
變量 -> @build_number
xcargs: "BUILD_VERSION='#{@build_number}'"
~或~
變量 -> ENV["BUILD_NUMBER"]
xcargs: "BUILD_VERSION='#{ENV["BUILD_NUMBER"]}'"
完整示例:
@build_number = latest_testflight_build_number(app_identifier: @AppBundleID) + 1
increment_build_number(build_number: @build_number)
build_app(scheme: "Release", export_method: "app-store", xcargs: "BUILD_VERSION='#{@build_number}'")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.