[英]Fastlane: How can I "increment_build_number" of one target only?
我的 Xcode 項目中有兩個目標:
在 increment_build_number 動作之后,他們都轉向:
但我期望的是將它僅應用於一個目標。 所以當我再執行一次這樣的事情時: increment_builder_number(scheme: "MyAwesomeAppScheme")
他們轉向:
有沒有辦法實現它? 謝謝!
我可以輕松地將此選項添加到fastlane
操作中,但需要等效的agvtool
來執行此操作。 increment_build_number
步驟主要是圍繞agvtool
的包裝。
您可以在 Apple 的文檔中找到更多信息: https : //developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/agvtool.1.html
將要碰撞的 .plist 文件指定為參數怎么樣? 就像是:
plist_path: "./Info.plist"
我的Xcode項目中有兩個目標:
在increment_build_number操作之后,它們都變為:
但是我希望僅將其應用於一個目標。 因此,當我再執行一次這樣的操作時increment_builder_number(scheme: "MyAwesomeAppScheme")
他們轉向:
有辦法實現嗎? 謝謝!
我創建了我的自定義通道,通過使用“xcodeproj”能夠為特定目標名稱設置版本和內部版本號。
# Sets the "VERSION" and "BUILD" number for a target
#
# @param args [Hash] Key value arguments. All the values are Strings. List:
# - target_name: The name of the target (REQUIRED)
# - version: The version number to be used (REQUIRED)
# - build: The build number to be used (REQUIRED)
#
desc "Sets the \"VERSION\" and \"BUILD\" number for a target"
lane :set_version_build_number do |args|
puts("\"set_version_build_number\" lane with ARGUMENTS: #{args}")
target_name = args[:target_name]
version = args[:version]
build = args[:build]
raise(StandardError, "Invalid ARGUMENTS for: \"set_version_build_number\" LANE") unless (
target_name != nil &&
version != nil &&
build != nil
)
puts("Variables:")
puts("\ttarget_name: #{target_name}")
puts("\tversion: #{version}")
puts("\tbuild: #{build}")
project_url = find_xcode_project()
raise(StandardError, "Invalid Xcode project for: \"set_version_build_number\" LANE") unless project_url != nil
project = Xcodeproj::Project.open(project_url)
xc_target = project.targets.find { |target| target.name == target_name }
raise(StandardError, "Invalid target for: \"set_version_build_number\" LANE") unless xc_target != nil
xc_target.build_configurations.each { |build_configuration|
build_configuration.build_settings["MARKETING_VERSION"] = version
build_configuration.build_settings["CURRENT_PROJECT_VERSION"] = build
}
project.save()
end
在哪里:
# Finds the location for an Xcode project within the current directory and all his parents
#
# @return [String] Full path to the Xcode project or nil if unsuccess
#
def find_xcode_project ()
absolute_dir_path = Dir.getwd
loop do
entries = Dir.entries(absolute_dir_path)
index = entries.find_index{ |entry| entry.include?(".xcodeproj") }
if index != nil
return "#{absolute_dir_path}/#{entries[index]}"
end
absolute_dir_path = File.dirname(absolute_dir_path)
if absolute_dir_path == nil || absolute_dir_path == "/"
break
end
end
return nil
end
它可以很容易地使用:
bundle exec fastlane set_version_build_number target_name:TargetApp version:2.0 build:3
當然不要忘記將其添加到 Fastlane 文件中:
require "xcodeproj"
並將其放入 Gemfile
gem "xcodeproj"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.